I have problem with Internet Explorer
Here is a sample of script with AJAX and jQuery and works fine in other browsers but in IE
it doesn't
index.html
<form enctype="multipart/form-data" method="post">
<input name="file" type="file" multiple="true" id="file" />
<input type="button" value="Upload" /> or clic "U"
</form>
ajax.js
$(':button').click(function(){
var formData = new FormData($('form')[0]);
$("#data").html(formData);
$.ajax({
url: 'upload.php', //server script to process data
type: 'POST',
xhr: function() { // custom xhr
myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // check if upload property exists
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // for handling the progress of the upload
}
return myXhr;
},
//Ajax events
//beforeSend: beforeSendHandler,
success: function(html) {
$("#php").html(html);
$("#file").val('');
},
error:function(html) {
$("#php").html(html);
},
enctype: 'multipart/form-data',
// Form data
data: formData,
//Options to tell JQuery not to process data or worry about content-type
cache: false,
contentType: false,
processData: false
});
});
Works fine in other browsers but in Opera
and IE
it is not working.
This is the CONSOLE(F12
) erron on IE
SCRIPT5009: 'FormData' is undefined
ajax.js, line 53 character 9
What should I do to solve the problem?