>  기사  >  백엔드 개발  >  $.ajax为什么自定义的options无法传进去给回调

$.ajax为什么自定义的options无法传进去给回调

WBOY
WBOY원래의
2016-06-23 13:38:47801검색

$.ajax为什么自定义的options无法传进去给回调????

//单击执行AJAX请求操作function clickSubmit(sendUrl, data, _sucmsg, _errmsg){	$.ajax({		type: "POST",		url: sendUrl,		dataType: "json",		timeout: 20000,		data: data,		sucmsg: _sucmsg,		//????????????????????????		errmsg: _errmsg,          //????????????????????????		success: function(data, textStatus) {			if (data.status == 1){				$.dialog.tips(this.sucmsg ? this.sucmsg : data.msg, 2, "32X32/succ.png", function(){					//location.reload();			    });			} else {				$.dialog.alert(this.errmsg ? this.errmsg : data.msg);			}		},		error: function (XMLHttpRequest, textStatus, errorThrown) {			$.dialog.alert("状态:" + textStatus + ";出错提示:" + errorThrown);		}	});}


回复讨论(解决方案)

可以的!
你看看回调函数的 data 参数是什么

//单击执行AJAX请求操作function clickSubmit(sendUrl, data, _sucmsg, _errmsg){	$.ajax({		type: "POST",		sucmsg: _sucmsg,		//????????????????????????		errmsg: _errmsg,          //????????????????????????		success: function(data, textStatus) {			alert(this.type); //////////弹出type                        alert(this.sucmsg);//弹出未定义,说明jquery.ajax的options不能自定义自己的		}	});}




应该是你的参数 _sucmsg 没有传入

晕。真行啊。昨晚不知哪弄错。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.