[SOLVED] $.ajax fails only on IE6
Update: the problem turned out to be in the JSON outputted by the ajax page:
-
[ {Address: 'address', City: 'city', Province: 'province', PostalCode: 'postalcode', }]
IE was choking on the trailing comma after the PostalCode key-value pair. I'm used to writing dictionaries in Python where a traililng comma isn't a problem, so I didn't even notice it for awhile.
------------
Hi All,
I've written the following function to update input fields in a form based on the option selected, and it's throwing an error only on IE6 (it works consistently on Firefox 3 and Chrome/Webkit).
On IE it returns the following error information:
XMLHttpRequest =
textStatus = parsererror
errorThrown = undefined
Here's the function:
-
function ajax_get_instructor_address() {
if (document.getElementById('add_session_instructor_username')) {
var SelectedPein = $('#add_session_instructor_username option:selected').val()
var ajaxUrl = '/tools/training/ajax/ajax_get_instructor_address.asp';
//alert('ajaxUrl = ' + ajaxUrl);
$.ajax({
url: ajaxUrl,
cache: false,
data: { sNip: SelectedPein },
dataType: 'json',
success: function(data, textStatus) {
// populate form input fields with data
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
// display error details
}
});
}
}
Any suggestions on what's going wrong and how to fix it?