views:

1061

answers:

1

I'm having problems with IE6 and javascript applied to ajax content.
I'm not able to use any sort of javascript (plain or with jQuery) on the content that is retrieved with ajax.

I have my main html page that loads the Header content with ajax (for this task I'm using the jQuery .load() method)
Something like

<html>
<body>
<div id="header">
... here the content that comes from the ajax call... 
   (i.e. <div id="myText">myText loaded with ajax</div>)
...

Now I'm trying to add some events to this content. This is working fine in Firefox and Chrome but not in IE6. I tried with jQuery live(), plain javascript loaded inside the ajax content but nothing. IE doesn't like it. Do you have any workaround for this issue? Thanks

Update
the script I'm using is like this

$("#goButton").live("click", function(){
    $search = $('#searchPhrase');
    if ($search.val() == $search.attr('title')) {
     $search.val('');
 }
});

this is the content that is loaded with the Ajax call

<form id="s" action="/searchresults.jsp">
    <input type="text" id="searchPhrase" title="Search" value="Search"/>                    
    <input type="image" alt="Search this Website" src="/images/go_button.png" id="goButton"/>
</form>

anyway the rendered page is quite big but every jQuery or js is working fine in IE if I don't consider the ajax content.

+2  A: 

Thing to check are:

1) Does the page validate at w3c. Ensure you check this pre and post ajax request. Firebug will help you here to get the raw html after the ajax request. Your issue could be duplicated id's or a malformed dom after you load the content which is causing ie to fail.

2) Does ie show any error messages, have you got debugging switched on in the tools->options?

3) Does the ajax request & response work in ie (Use Fiddler2 to check this).

4) Report back after all the above succeed.

redsquare
Hi redsquare, thanks for your response. The document is not passing the w3c validation due to some error. I'll have a look and fix all these problems. Anyway now I know that is not a specific IE6 issue with ajax and javascript. I'm gonna use your 'Things to check' list to sort out what the problem is. Thank you again.
al nik
Add to the list: 5) Check internet zone security settings that active x is not disabled.
Moak