In salesforce, on hitting a button I need to call a web service url through an ajax call.
Please check my code below :
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var response = xmlhttp.responseText;
}
}
var requrl ='my webservice url';
alert(requrl);
xmlhttp.open("POST",requrl);
xmlhttp.send();
When I hit this 'requrl' manually on browser, it works fine. Can anyone tell me what I am doing wrong above or provide me a sample code against this?