Reputation: 898
I know i am proberly being dumb or something but for the life in me i cannot get this function to work in IE7+, works in every other non IE browser:
/inbox/get_auth_replies (JSON Returned):
{"default_message":"Thank you, we have already recieved your request. A member of the team will contact you shortly.","repeated_message":"Thank you for contacting us. A member of the team will contact you shortly."}
jQuery:
var $keyword_id = 123;
$.post('/inbox/get_auto_replies', {keyword_id: $keyword_id}, function(resp) {
console.log(resp.default_message);
$('#inbox_default_message').val(resp.default_message);
$('#inbox_repeat_message').val(resp.repeated_message);
}, 'json');
in IE reports:
SCRIPT5007: Unable to get value of the property 'default_message': object is null or undefined.
I can see it is returning the data but just cannot see/parse it?
I have looked at everything on SO and nothing seems to help.
Any help would be appreciated.
Thanks.
Upvotes: 0
Views: 792
Reputation: 35223
Change $.post
to $.ajax
and make use of the error callback and log the error.
I would suggest changing var $keyword_id = 123;
to var keyword_id = 123;
Use $
before a variable name when indicating that its a jquery dom element
Upvotes: 1
Reputation: 3939
Have you tried using jQuery.getJSON
instead? Same structure as the .post (minus the 'json' parameter).
Could then loop through the items to try and work it out and alert/console.log them?
http://api.jquery.com/jQuery.getJSON/
It might be a case of not being able to parse the JSON in IE7, does it work in IE9 (if you can try it). I know you mentioned IE7+, but which have you tried? I think there is native JSON parsing in IE8 onwards.
Upvotes: 0