tags:

views:

60

answers:

3

I'm using a simple line of jquery to load a new "song meaning" when a link is clicked. This works fine on Chrome and IE, but it doesn't change in Firefox. I'm passing the song ID with the 'sid' variable so that the loadmeaning.php knows what song we're looking for.

$('#songmeaning').load('/music/ajax/loadmeaning.php', "sid="+id);

I turned on Firebug and I notice that it is actually pulling the data from loadmeaning.php successfully, it just doesn't replace the content of #songmeaning - and again, only in Firefox.

Has anyone else run into this problem, or can offer some tips?

Here's the HTML used around the songmeaning element

<div class="meaning">
    <div id="refresh" onclick="refreshMeaning(<?=$songID;?>)"><img src="/images/refresh_icon.png" height="16" width="16" title="Load More Meanings"></div>
    <div id="songmeaning" class="indent"><?=$songMeaning;?></div>
</div>

Thanks.

+1  A: 

Double-check your DOM structure to ensure that songmeaning is truly a unique ID. If it's not unique, different browsers may give you different results when you try to use it. Other than that, I can't think of anything. Do you get any errors in Firebug?

Edit Right now (2010-10-29 22:24 BST) clicking that refresh link doesn't do anything for me in either Firefox or Chrome. The code is:

$('#songmeaning').get('/music/ajax/loadmeaning.php', "sid="+id);

That get should be load. But I'm assuming you've made some change? Since your title says load...

Edit Right now (2010-10-30 09:07) it works just fine on Firefox 3.6, the code has changed again:

$('#refresh').html("<img src='/images/loading.gif' height='20' width='20' title='Loading'>");
$('#songmeaning').fadeOut('fast');
var refreshIcon = function refreshIcon() { $('#songmeaning').fadeIn(); $('#refresh').html("<img src='/images/refresh_icon.png' height='16' width='16' title='Load More Meanings'>"); }
$('#songmeaning').load('/music/ajax/loadmeaning.php', "sid="+id, refreshIcon); 
T.J. Crowder
The only errors I see are from Google Ads. Here's one of the pages we use this. http://www.greendayauthority.com/music/song/43/ Scroll down to "Song Meanings". As best I can tell, songmeaning is unique.
scatteredbomb
@scatteredbomb: Your link worked for me on both Chrome and Firefox.
Marwelln
@Marwelln When you click the "Refresh" link (double arrows in song meanings) it loads fine for you? It works in IE and Chrome on my machine - but not Firefox (4.0 beta).
scatteredbomb
@scatteredbomb: I've just updated my answer, right now it looks completely nonfunctional. Did you change `load` to `get` for some reason? (If so, you want to change it back.)
T.J. Crowder
I changed it back. Was just trying a suggestion from below in case I had misused the load() function - but I saw your comment. So could you take another look and see if you see any problems? Thanks.
scatteredbomb
@scatteredbomb: Updated again, works just fine in Firefox 3.6
T.J. Crowder
@scatteredbomb: Yes, it worked when I clicked "refresh".
Marwelln
@scatteredbomb: What was it about the answer that was right?
T.J. Crowder
+2  A: 

Are you trying to replace with new content like

$('#songmeaning').html('new data from server');

or


$('#songmeaning').text('new data from server');
zod
A: 

Do you see the response text in Firebug? If it shows an empty response, it is likely a cross-domain security issue. Otherwise, try using get instead of loadand put console.log(arguments) in the callback function.

For what it's worth, the page works fine for me in FF3.6.

Tgr
*"Do you see the response text in Firebug?"* Yes, he said he did in his original question. *"If it shows an empty response, it is likely a cross-domain security issue."* He's showed us the `load` call, which clearly isn't a cross-domain call.
T.J. Crowder
@T.J. Crowder: it can be, for example when there is a base tag with a different domain name. And cross-domain calls in Firefox (at least FF3.*) seem to return successfully, with a HTTP 200, but the response text is an empty string. It wasn't clear from the OP whether or not that was the case.
Tgr