I have a lot of googled but I have not found any solution
I use jQueryUI Dialog and ajaxSubmit to send data (files and others) through a modal dialog and Ajax.
My problem is very simple: data is sent correctly to the server, but not through ajax, i.e. no request header attributeX-Requested-With=XMLHttpRequest
So what am I doing wrong or is there some kind of known issue?
Here is a snippet of my code.
$('#photo-dlg').dialog({
modal: true,
open: function() { $(this).load("/mywebsite/mydialog");}
buttons: {
'cancel' : function() {$(this).dialog('close');},
'submit' : function() {
$('#formid').ajaxSubmit({
dataType: "json",
success: function (data) { $('#photo-dlg').dialog('close'); })
});}
});
By the way, I tried options like:
headers: {"X-Requested-With":"XMLHttpRequest"}
data: {"X-Requested-With":"XMLHttpRequest"}
beforeSend: function(xhrObj) {xhrObj.setRequestHeader("X-Requested-With", "XMLHttpRequest")}
without success
UPDATE:
You can copy / paste the following code into the html page and try it yourself through FireBug (=> No X-Requested-With header)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://d23fbyuk1dcxop.cloudfront.net/js/jquery/jquery.multiselect-1.8.min.gz.js"></script>
<script type="text/javascript" src="http://d23fbyuk1dcxop.cloudfront.net/js/jquery/jquery.form.min.gz.js"></script>
</head>
<body>
<div id="photo-dlg2">
<form id="updatePhoto2" enctype="multipart/form-data" elementid="updatePhoto2" name="updatePhoto2" method="POST"
action="http://mywebsite.com/article/updatePhoto">
<input type="file" size="50" class="easyinput" id="photoFile" name="photoFile">
</form>
</div>
<script type="text/javascript">
$('#photo-dlg2').dialog({
modal: true,
buttons: { 'submit' : function() {
$('#updatePhoto2').ajaxSubmit({
dataType: "json",
success: function (data) {
alert(data['status']);
}
});
}}
});
</script>
</body>
</html>