Reputation: 21817
I try to send to httpbin request with prototype.js
My code:
function loadTest()
{
new Ajax.Request('http://httpbin.org/get', { method:'get',
// success request
onSuccess:
function(transport) {
alert("Success! \n\n" + transport.status);
},
// fail request
onFailure:
function() {
alert('Something went wrong...');
}
});
}
After execution i got: Success!
and transport.status = 0
Why? How can i correctly send request and get response with prototype.js?
Thank you.
Upvotes: 1
Views: 572
Reputation: 13421
There is nothing wrong in your code, except for one thing, You cannot make cross-domain XMLHttpRequest
.
You should use a proxy that enables CORS.
Another option is JSONP request.
As I see both of them is not available for httpbin.
Upvotes: 2