General question about jquery load function


(Mahearnpad) #1

This is not specifically about Matrix, but it's something I'm using to do some ajax stuff on matrix pages.


There seems to be an issue with IE8 (maybe IE7 also) and the jquery load function. Using it to load the online poll results into the page, asynchronously to replace the poll questions works fine in firefox, but doesn't get rendered to the screen in IE8. The poll questions div collapses with nothing in it. I'm using jQuery 1.4.2.



No JS errors in IE btw. Has anyone else come across this and found a fix?



thanks

Michael


(Nic Hubbard) #2

jQuery should not have any issues as it is very thoroughly tested in all browsers. Do you have a page that we can look at?


(Mahearnpad) #3

[quote]
jQuery should not have any issues as it is very thoroughly tested in all browsers. Do you have a page that we can look at?

[/quote]



Sure Nick, thanks for offering to help.

Here is the URL of the page: http://www.nps.org.au/consumers/medicinewise_skill/topic_text_template/_nocache. You will see the jquery code near the bottom of the page.

Half-way down is a poll (right hand floated div). The functionality is that the vote is posted asynchronously, and on success I fetch the results and shove them into the same div (using the jquery load function). It works in FF, but in IE - noting happens until you click somewhere on the page, and then the div collapses with no content.


(Nic Hubbard) #4

[quote]
Sure Nick, thanks for offering to help.

Here is the URL of the page: http://www.nps.org.au/consumers/medicinewise_skill/topic_text_template/_nocache. You will see the jquery code near the bottom of the page.

Half-way down is a poll (right hand floated div). The functionality is that the vote is posted asynchronously, and on success I fetch the results and shove them into the same div (using the jquery load function). It works in FF, but in IE - noting happens until you click somewhere on the page, and then the div collapses with no content.

[/quote]



I am not seeing the poll, does it have public permissions?



Also, I see that jQuery is included twice in your page, and each is a different version. I wonder if this could cause some issues.


(Mahearnpad) #5

[quote]
I am not seeing the poll, does it have public permissions?



Also, I see that jQuery is included twice in your page, and each is a different version. I wonder if this could cause some issues.

[/quote]



Sorry, it wasn't live. Try again. The page was under construction - I've had to make it live so you could see it.



BTW - noticed that there is a current ticket in jquery bug tracker (Ticket #7737 (pending bug)), which seems to be similar to my problem.



M


(Mahearnpad) #6

[quote]
Sorry, it wasn't live. Try again. The page was under construction - I've had to make it live so you could see it.



BTW - noticed that there is a current ticket in jquery bug tracker (Ticket #7737 (pending bug)), which seems to be similar to my problem.



M

[/quote]



I think I've found the answer. The URL I'm using as a parameter in the load function has a query string (./?a=113562?SQ_ACTION=page_poll_113562_results), as I need to get the results, not the questions. This causes IE to spit the dummy. FF handles it OK.



Any ideas out there?? I've already lost all my hair :wink:


(Nic Hubbard) #7

[quote]
I think I've found the answer. The URL I'm using as a parameter in the load function has a query string (./?a=113562?SQ_ACTION=page_poll_113562_results), as I need to get the results, not the questions. This causes IE to spit the dummy. FF handles it OK.



Any ideas out there?? I've already lost all my hair :wink:

[/quote]



Can you just use %globals_asset_url:113562% ? Are you saying the URL is not getting expanded?


(Mahearnpad) #8

[quote]
Can you just use %globals_asset_url:113562% ? Are you saying the URL is not getting expanded?

[/quote]



Tried that, but I need to append the query string to it, otherwise I just get the poll questions again. The URLs are looking OK in the source. The keyword with or without query string still doesn't work in IE.


(Benjamin Pearson) #9

[quote]
I think I've found the answer. The URL I'm using as a parameter in the load function has a query string (./?a=113562?SQ_ACTION=page_poll_113562_results), as I need to get the results, not the questions. This causes IE to spit the dummy. FF handles it OK.



Any ideas out there?? I've already lost all my hair :wink:

[/quote]



Is it the double question mark causing the trouble?


(Mahearnpad) #10

[quote]
Is it the double question mark causing the trouble?

[/quote]



Nuh, I'm using single quotes around strings.


(Mahearnpad) #11

I think Nick was on the mark with the observation that we have 2 jquery libraries loaded. I've done a test page which didn't work with both, but then worked when 1 was removed. The problem is that the one that needs removing is an older library that is loaded in a global design file. I'm still not completely sure this is the answer, but it seems likely now.


<< Editing this after some more testing: this still doesn't work - so I don't think it is the 2 jquery libraries now. Feel like I'm chasing my tail now.


(Jaco Roeloffs) #12

I don't have permissions to see the page you posted, but if it's just load that's affected, why not use get instead?


$.get('urltoyourpage', function(whatyougotback){

$thingyouwant = $(whatyougotback).find("#whatyouarelookingfor");

$("#whereyouwanttoputit").html($thingyouwant);

});


(Mahearnpad) #13

[quote]
I don't have permissions to see the page you posted, but if it's just load that's affected, why not use get instead?



$.get('urltoyourpage', function(whatyougotback){

$thingyouwant = $(whatyougotback).find("#whatyouarelookingfor");

$("#whereyouwanttoputit").html($thingyouwant);

});

[/quote]



Thanks for suggesting this option. Sounds very sensible - I'll give it a go tomorrow.


(Mahearnpad) #14

[quote]
Thanks for suggesting this option. Sounds very sensible - I'll give it a go tomorrow.

[/quote]



Afraid to say that I get the same results from the GET method.



Just looking at the html source, and there are multiple divs with the same id (on the poll results output from Matrix). Do you think this sort of thing would cause a problem with IE? The other thing is that there is no name attribute, which is, I thought, required for IE when using getElementByID type selections (assume jQuery uses this - but maybe it compensates for the missing attributes).



Anyway, as usual, the answer is probably something very simple, but need to work through all the most complicated issues first.


(Mahearnpad) #15

[quote]
Afraid to say that I get the same results from the GET method.

[/quote]



We've found the answer. Our designs were too complex (messy) for IE, and it seems it was choking at the .find() point, where it tries to get the specific section of content (#blah) to go in the div after the load() or get() has successfully retrieved the page content.



Thanks to everyone who gave their advice.