if you are using jquery then by using plugin formInteract, you just need to do this.
//just keep the html as it is.
<input name="searchTxt" type="text" maxlength="512" id="searchTxt" class="searchField"/>
at bottom of the page just include this plugin file and write this code.
//initialize one time at the bottom of the page.
var search= $("#searchTxt).formInteract();
search.getAjax("http://www.myurl.com/search/", function(rsp){
//now do whatever you want to with your response
});
or if using parameterized url then use this.
$.get("http://www.myurl.com/search/"+search.get().searchTxt, {}, function(rsp){
//now do work with your response;
})
here is the link to project https://bitbucket.org/ranjeet1985/forminteract
You can use this plugin for many purposes like getting the value of a form, putting values into a form, validation of forms and many more. You can see some example of code in the index.html file of the project.
Of course i am author of this project and all are welcome to make it better.
inputElement.value
. The answers below show different ways to get hold of a reference to a specific inputElement – Jonny Leeds Feb 6 at 12:57