Pass more than one variable to the beforeSend function via $ .ajax

I have the following Ajax call:

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");
}

I want to pass the url variable to the passToProxy function (I want to replace "http: // localhost: 8088 / mockSDClientSOAPBinding" with the url variable), but I don’t think I have the right idea here, A warning in passToProxy pops up "undefined". What am I doing wrong?

+3
source share
1 answer

Perhaps you want to:

beforeSend: function(xhr){ passToProxy(xhr, url); }
+6
source

All Articles