简体   繁体   中英

Is Jquery broken? Why does Jquery Load fn not work in IE?

Jquery seems to have difficulty in IE (6,7,8) loading using the load() function when there are url's with parameters (example: getdata.php?id=2444)

I am having this problem, but it seems this question is common and has never been resolved:

see

JQuery load() in IE8 POST&GET not working? jQuery's .load() not working in IE - but fine in Firefox, Chrome and Safari

Why hasn't this issue been fixed? Is there a solution using Jquery?

jQuery's $.load function has a data parameter which takes JSON-serialized values and converts them to GET variables. Try this:

$.load('getdata.php', { 'id': 2444 });

Since $.load() is just a wrapper of $.ajax(), you can find more info at the $.ajax() page (go to the options tab, look for the data parameter). It was constructed this way to easily allow them to prevent caching (which is done by a GET variable of the timestamp) and do some nifty JSON serialization tricks (with the goal of making it easy to use JavaScript datatypes), such as:

var foos = ['bar1', 'bar2'];
$.load('getdata.php', { 'foo': foos });

The request for the above example: getdata.php?foo=bar1&foo=bar2

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