Possible Duplicate:
X-Requested-With header not set in jquery ajaxForm plugin
I have a web application written mostly in xQuery that uses Malsups Ajax form plugin to submit a webform via an Ajax call. In my xQuery, I send a json object back as the server response and that object's properties are analyzed in my post-submit callback function.
My app runs successfully in Chrome, Firefox, and even IE10, but not in IE9. In IE9, the Ajax form plugin fails when receiving the server response and my post-submit function does not fire at all. All my browser returns is a file containing the server response: the raw JSON object.
I noticed while debugging in Fiddler that I am missing a header: X-Requested-With: XMLHttpRequest. I've been trying to add this header manually by referencing the following related questions but with no luck:
X-Requested-With header not set in jquery ajaxForm plugin
XMLHttpRequest not adding header - “X-Requested-With: XMLHttpRequest”
My form does have a file input field, but I've read on a SO post that this has been patched by Malsup in his plugin and multipart/form-data forms are supported. I've also read some posts saying IE9's activeX settings may be messing with things.
Is this missing header the root of my problem? If so, is there a quick way to add it?
Code Samples:
$(document).ready(function() {
var options = {
success: showResponse //post-submit callback
}
$('submitFormbutton').click(function(){
$().modal() //create popup dialog window on form submit
});
}
// ajaxForm plugin, prepares the form and invokes ajaxSubmit at the right moment
$("myForm").ajaxForm(options);
function showResponse(responseText, statusText, xhr, $form) { // post-submit callback
// parsing JSON object here which is in responseText
if ($(responseText).property == "blahblah") {
do something here
}
else { do something else here }
Thanks in advance.