jQuery POST with remote HTTPS resource
Hi
I put together a sample web page to perform this POST, but errors with
statusText of "error" and the error response object has nothing more. I also tried to scope this under
Fiddler 2 , and I did not even see a request being made. A successful response is expected to contain a JSON object.
I have viewed many
jQuery $.post() examples elsewhere, and they all use a url value that assumes it is within the same host (using a partial path) and not remotely (using a full path).
Is it the case that jQuery $.post() not intended to be access remote services?
Note that I tried accessing the same endpoint via Java, PHP, and C#, and there were no issues.
Below is that simple web application page.
- <!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script >
</head>
<body>
<form id="foo">
<input type="submit" value="Send" />
<p>success: <div id="success" name="success" style="color:green; font-weight:bold;"></div></p>
<p>error: <div id="error" name="error" style="color:red; font-weight:bold;"></div></p>
</form>
</body>
<script type="text/javascript">
function successResponse(response) {
$('#success').html(response);
}
function errorResponse(request, status, error) {
$('#error').html(status);
}
function getAvailableBalance(username, password)
{
try
{
var input = '{"username":"' + escape(username) + '","password":"' + escape(password) + '"}';
$.post(" https://int.tangocard.com/Version2/GetAvailableBalance ", input, successResponse ).error(errorResponse);
}
catch( error )
{
alert('Exception Handler: Error:' + error.name + ',' + error.message);
errorHandler(error)
}
}
$("#foo").submit(function(event){
getAvailableBalance( " third_party_int@tangocard.com ", "integrateme");
event.preventDefault();
});
</script>
</html>
Thank you for any assistance.
Jeff in Seattle