views:

159

answers:

1

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

http://stackoverflow.com/questions/1174945/jquery-load-in-ie8-postget-not-working http://stackoverflow.com/questions/1061525/jquerys-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?

+4  A: 

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

cpharmston
Wow? Leaky abstractions, these.
Yar
I edited my answer a bit to explain it. It's certainly a leaky abstraction, but there are also some neat benefits.
cpharmston
Very interesting. Assuming this is intentional, can I also assume it's documented somewhere? Aside from here, I mean: http://groups.google.com/group/jquery-en/browse_thread/thread/18f03016212cf049
Yar