简体   繁体   中英

jQuery interfering with javascript search function (passing parameters)

I have a pretty basic mobile html site with javascript search to give it offline search functionality. I put in jquery mobile in order to have a fixed toolbar (using phone gap and the ccs fixed position is not supported). The problem now is that jquery has affected the search functionality by changing the parameters being passed.

You can see the problem when looking at the url.

For example:

If I search for 'stackoverflow'

The url should be the following: search.html?searWords=stackoverflow

Below is what is created (note the search box value is 'Search Specs') search.html?searWords=stackoverflow&Send=Search+Specs

If I take out the 'Search Specs' from the search button the code just leaves it out, but I get the same result: search.html?searWords=stackoverflow&Send=

So in a nutshell, the jquery mobile scripts 'jquery-1.6.4.min.js' and 'jquery.mobile.min.js' are inserting &Send=”value of search button” on the end of the url when the search function is used.

This is because jQuery mobile uses AJAX navigation by default, meaning it will intercept all links and forms on all your pages and navigate them using URL's like the one you specified (eg page.html#page2.html ). This applies to forms as well.

If you can live without this feature, you can turn it off by using ajaxEnabled option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM