我有以下Ajax调用:
function ajaxCall(soap, url){
// Post SOAP request.
$.ajax({
type: "POST",
url: url,
contentType: "text/xml",
data: soap,
dataType: "xml",
processData: false,
beforeSend: passToProxy(url),
success: onSuccess,
error: function(){
getRandom();
}
});
}
function passToProxy(xhr,url1) {
alert(url1);
// Pass the target URL onto the proxy.
xhr.setRequestHeader("SOAPTarget","http://localhost:8088/mockSDClientSOAPBinding");
// Pass the action onto the proxy.
xhr.setRequestHeader("SOAPAction","invoke");
}
我希望能够将url变量传递给passToProxy函数(想要用变量url替换“http:// localhost:8088 / mockSDClientSOAPBinding”),但我认为这里没有正确的想法。 passToProxy中的警报弹出“未定义”。我做错了什么?
答案 0 :(得分:6)
也许你想要:
beforeSend: function(xhr){ passToProxy(xhr, url); }