How can I pass parameters to the XMLHttpRequest Object?
function setGUID(aGUID) {
var xhReq = new XMLHttpRequest();
xhReq.open("POST", "ClientService.svc/REST/SetAGUID" , false);
xhReq.send(null);
var serverResponse = JSON.parse(xhReq.responseText);
alert(serverResponse);
return serverResponse;
}
I need to use javascript instead of jquery, in jquery I got it to work with this code, but cant seem to figure it out the straight javascript way..
function setGUID(aGUID) {
var applicationData = null;
$.ajax({
type: "POST",
url: "ClientService.svc/REST/SetAGUID",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ aGUID: aGUID }),
dataType: "json",
async: false,
success: function (msg) {
applicationData = msg;
},
error: function (xhr, status, error) { ); }
});
return applicationData;
}