I know that are a lot of posts about consuming a WCF REST through JQuery/JSON, but I can\'t get it to work. I\'m currently stuck at a date parameter. Below is my C# method:<
Alsalaam Aleykum.
All you have to do is to respond to the error. I mean change the date format so the json can parse it to the web service.
your code should look like this:
function botaoclick() {
var date = new Date();
date = "\/Date(" + date.valueOf() + ")\/";
// valueOf() method Returns the primitive value of a Date object.
var datavar = {
'pDtTimeStampTransac': date,
'pIDResource': 1,
'pQty': 1
};
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "YOUR URL",
dataType: "json",
data: JSON.stringify(datavar),
error: jqueryError,
success: function(msg) {
alert("back");
var divForResult = document.getElementById("test");
divForResult.innerHTML = "Result: " + msg.d + "";
}
})
}
function jqueryError(request, status, error) {
alert(request.responseText + " " + status + " " + error);
}