I can successfully receive values from my web service so in that repect the script is working fine. However I am now trying to send data to the webservice using the ‘data’ field below. What i cant figure out is how to send a simple string (e.g. “test”) to the web service which is what my web method expects as a parameter.
Any help is much appreciated. For example:
function setQuestion() {
$.ajax({
type: "POST",
**data: "{}",** //how do i use this to send a string??
dataType: "json",
url: "http://someURL",
contentType: "application/json; charset=utf-8",
success: onSuccess
});
}
function onSuccess(msg) {
$("#questiontxt").append(msg);
}
For asmx you need to pass a stringified version of the data object, so for example:
Or you can hava an object and use jquery-json
Finally, your web service class must look like: