欢迎各位兄弟 发布技术文章
这里的技术是共享的
function showRequest(formData, jqForm, options) {
return true;
}
function showResponse(responseText, statusText, xhr, $form){
if(responseText.error!=null && responseText.error!=''){
alert(responseText.error);
}else if(responseText.pic!=null && responseText.pic!=''){
$('#'+current_upload_img_id).attr('src',responseText.pic);
$('#'+current_upload_img_id).siblings("input[name='operation_imgs[]']").val(responseText.storage_pic_url);
}else{
alert('上传有错误')
}
};
var options = {
type : 'POST',
beforeSubmit: showRequest,
success: showResponse,
dataType: 'json',
: function(data, statusText, xhr, $form) {
console.log(data);
console.log(statusText);
console.log(xhr);
console.log($form);
}
};
$("input[name='operation_img_ajaxs[]']").change(function(){
current_upload_img_id = $(this).siblings('img').attr('id');
//$('#pingpaiadd').ajaxForm(options).submit();
$('#operations_form').ajaxSubmit(options);
return false;
});$(this).ajaxSubmit({
type: "POST", // Enter Request type GET/POST
url: 'action.php', // Enter your ajax file URL here,
dataType: 'json', // If you are using dataType JSON then in php file use die( json_encode($resultArray) );
cache: 'false',
data: {_keyName: "abcd"}, // Put your values here
beforeSend: function(){
alert('before')
},
success: function(data){
alert('success')
},
: function(data,status,xhr,$form) {
console.log(data);
}
});来自 https://stackoverflow.com/questions/29138742/ajaxsubmit-error-case