Reputation: 4919
I have an ajax call in my page, i use for this particular task the jQuery library. In the response of the ajax call i'd like to parse the response message.
The problem is that this code gives me an error message at IE 6-7-8 (the weirdness is that IE 9 works perfectly and Firefox works perfectly):
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Mon, 12 Aug 2013 08:20:03 UTC
Message: Object doesn't support this property or method
Line: 94
Char: 4
Code: 0
Any idea is highly appreciated. Looks like this this line is generating error:
response_str = $(server_response).filter("#response").val();
I copy my code related part:
$.ajax({
type:'POST',
url:'ajax.php',
processData: 'false',
data:{
data1: 'val1'
ajax:'true'
},
dataType: "html",
contentType: ''application/x-www-form-urlencoded''
})
.done( function(server_response) {
//the following line generate error
response_str = $(server_response).filter("#response").val();
}
})
}');
Upvotes: 3
Views: 2167
Reputation: 35213
Why not just find()
it?
response_str = $(server_response).find("#response").val();
response_str = $(server_response).filter(function(i, el){
return $(el).is('#response');
}).val();
The code above assumes that there only is one element with the id "response".
Upvotes: 1