Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

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 be able to pass the url variable to the passToProxy function (want to replace "http://localhost:8088/mockSDClientSOAPBinding" with a variable url), but I don't think I have the right idea here. The alert in passToProxy pops up "undefined." What am I doing wrong?

like image 796
Paul Erdos Avatar asked Dec 10 '25 20:12

Paul Erdos


1 Answers

Perhaps you want:

beforeSend: function(xhr){ passToProxy(xhr, url); }
like image 170
Doug Owings Avatar answered Dec 12 '25 11:12

Doug Owings



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!