I have a problem with my javascript function, I notice that the Http Post Request was not arriving at my server.. So I inserted a few alert boxes on my javascript code to see where was the problem..
Here is my javascript function:
function callService(id) {
id.innerHTML = "Clicked!";
alert("Before do XMLHttpRequest!");
var xmlhttp = new XMLHttpRequest();
alert("Before do url!");
var url = "http://this_is_an_address_valid_but_i_wont_show_you/";
alert("Before do open!");
xmlhttp.open("POST", url, true);
alert("Before do setRequestHeader!");
xmlhttp.setRequestHeader("Content-type", "application/json");
alert("Before do onreadystatechange!");
xmlhttp.onreadystatechange = function () { //Call a function when the state changes.
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
}
}
alert("Before do parameters!");
var parameters = JSON.stringify({"Values": {"Value": 2500,"ItemNumber": "1"},"PartnerID": "S","ProdCode": "C","TC": "111","OpCode": "10"});
alert("Before do send!");
xmlhttp.send(parameters);
alert("After do send!!");
}
I notice that I don't see the alert box "Before do setRequestHeader!" , so I guess the open method of the XMLHttpRequest is not working?
Thanks alot in advance, can someone help me?