I’m writing my first bit of jQuery, and I’m having a problem with jQuery.get(). I’m calling this;
$.get(url, updateList);
where updateList is defined like so;
function updateList(data)
{
if (data)
{
$('#contentlist').html(data);
}
else
{
$('#contentlist').html('<li><a href="#" id="synclink">Nothing found. Try again</a></li>');
}
}
The function runs, and updateList is called. It works fine in Internet Explorer. However, in Firefox, the data parameter is always empty. I would expect it to be filled with the content of the webpage I passed in as the URL. Am I using it wrong?
Notes;
- in Firebug, I’ve enabled the Net panel, and I get the request showing up. I get a
200 OK. TheHeaderstab looks fine, while theResponseandHTMLpanels are both empty. - The page I’m trying to download is a straight HTML page — there’s no problem with server code.
- The page with JavaScript is local to my machine; the page I’m downloading is hosted on the Internet.
- I’ve tried checking the URL by copy-pasting it from my page into the browser — it happily returns content.
- The error occurs even in Firefox Safe Mode — hopefully that rules out rogue addins.
You probably won’t be able to do this due to cross-domain security. Internet Explorer will allow you to Ajax remote domain when running from
file://, but Firefox and Chrome won’t.Try to put both files on the same server and see if it works (it should).