Reputation: 21480
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;
200 OK
. The Headers
tab looks fine, while the Response
and HTML
panels are both empty.Upvotes: 1
Views: 3300
Reputation: 4740
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).
Upvotes: 7
Reputation: 37126
Stick alert (or breakpoint in Firebug) and see if the data returned is not an object (or if there is any data). If the former - you may need to drill into the object to get your markup
Upvotes: 0
Reputation: 186562
You'll most likely need to fix your page that you're quering with XHR because it should be returning content. Copy paste the link in the Firebug net tab and make a new tab, and edit that page with your text editor so it spits content back.
Upvotes: 1