I want to send a parameter to webservice. The parameter must be a variable, not a fixed string. When I write the following code, the webservice is called fine and runs fine.
$(document).ready(function() {
$.ajax({
type: "POST",
url: "JsonTestService.asmx/Test",
data:"{'url':'http://www.cramster.com'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert(msg.d);
}
});
});
But when I change the line to the next, where x is a variable, it does not work. Can you tell me how to pass a variable to a web service in the following code.
data:"{'url':x}",
Mini
source
share