0

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?

Community
  • 1
  • 1
chris
  • 20,791
  • 29
  • 77
  • 90
  • Assuming cpharmston is right (sure sounds good), this would be truly interesting, since the other questions you mentioned on SO don't load anything with a querystring :) – Dan Rosenstark Oct 11 '09 at 00:30

1 Answers1

4

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

  • Wow? Leaky abstractions, these. – Dan Rosenstark Oct 11 '09 at 00:08
  • I edited my answer a bit to explain it. It's certainly a leaky abstraction, but there are also some neat benefits. –  Oct 11 '09 at 00:16
  • 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 – Dan Rosenstark Oct 11 '09 at 01:31