I need to send a json object via post and i cannot get it working. I have it so that it returns successfully but the response is empty and i cannot figure out why things i have tried are
new Ajax.Request("http://twittersentiment.appspot.com/api/bulkClassifyJsonRequests", {
method: "post",
postBody:JSONstring,
onSuccess: function(transport){
var response = transport.responseText;
alert("Success@ \n" + transport.responseText + "no response");
},
onFailure: function(){alert("try again")}
});
and
var http = new XMLHttpRequest();
http.open("POST","http://twittersentiment.appspot.com/api/bulkClassifyJsonRequests",true);
http.onreadystatechange = function() {
if(http.readyState == 4)
{
if(http.status == 200)
{
document.write(http.response.data);
}
else
{
alert(http.statusText);
}
}
};
http.send(JSONstring);
The Same Origin Policy is preventing that call from happening. You could install a proxy server in between to make those calls, and return the output to your AJAX script. See Why You Need a Proxy for more details.