You need to sign in to do that
Don't have an account?
Greg H
Status Code of Remote Server
I need to check the status code of a remote URL prior to allowing a POST. Since this POST would be to a domain other than salesforce, I believe I need to use the remoteFunction() call in the AJAX toolkit. I've set this up using the proxy proxy settings but cannot seem to figure out how to get only the "status code" piece of the response.
Code:
If you look at my function from above, you can see that I can get back "response" and when it does return it literally displays the content of the remote URL in the sControl. But I was hoping I'd be able to get back something like "response.status" or "response.statusCode" and simply use that code to determine if I should allow for the POST later in the sControl.
function getResponse() { sforce.connection.remoteFunction({ url : "http://remote.location.com/specific/page", method : "GET", mimeType : "text/xml", onSuccess : function(response) { document.getElementById("responseTXT").innerHTML = "<div style=\"font-weight: bold; color: #FF0000;\">SUCCESS!!!!</div><div>"+response+"</div>"; }, onFailure : function(response) { document.getElementById("responseTXT").innerHTML = "<div style=\"font-weight: bold; color: #FF0000;\">Failed:</div><div>"+response+"</div>"; } }); }
If you look at my function from above, you can see that I can get back "response" and when it does return it literally displays the content of the remote URL in the sControl. But I was hoping I'd be able to get back something like "response.status" or "response.statusCode" and simply use that code to determine if I should allow for the POST later in the sControl.
Any help is appreciated,
-greg
looking for status code 200 then you can check which method is called.
Otherwise you can modify connection.js function _remoteFunctionCallback()
to call your onSuccess with the XHR. Something like:
args.onSuccess(request.responseXML.documentElement, request);
Then in your callback:
function mySuccessCallback(response, xhr) {
alert(xhr.status);
}
HTHs,