我有以下代码:
$.ajax({
url: 'upload.php', //Server script to process data
type: 'POST',
xhr: function() { // Custom XMLHttpRequest
var 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: function(e) { $('#progress').css('display', 'block'); },
success: function(e) {
if (e != "bad" || e != "No") {
alert('File Upload Success!');
$('#imgsrc').attr("src", e);
$('#img').val(e);
} else {
alert('File Failed, Upload File of Size < 1MB');
}
} ,
error: function(e) { alert('error' + e.message); } ,
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
而不是去其他,响应bad
& No
。它在不同的故障上显示File Upload Success!
和添加图像src
为bad
和。No
If else 我做错了什么吗:-
upload.php 的响应是 :- FileName
, bad
, & No
。
谢谢