Click here to Skip to main content
14,427,730 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm trying to call the server side method and passing value with Json format using $.ajax() ,but I got this error:
"Message":"Invalid web service call, missing value for parameter: \u0027message\u0027.","StackTrace":" 

I would appreciate for your help.
client side code:
$('#submit_form').click(function () {
               if ($('#feedback_text').val() != '') {
               var values = { feedback : $("#feedback_text").val()};
                   $.ajax({
                       type: "POST",
                       url: "test2.aspx/ReceiveFeedback",
                       data: JSON.stringify(values),
                       contentType: "application/json; charset=utf-8",
                       dataType: "json",
                       processData: false ,
                       success: function (data) {
                          alert(data);
                       }
                   });
               }
           });

server side code:
[WebMethod]
   [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
   public static string ReceiveFeedback(string message)
   {
       string msg = "Thanks for your feedback";
       return msg;
   }
Posted
Updated 8-Nov-19 15:19pm
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Hello,

Change your calling code as shown below.
$('#submit_form').click(function () {
    if ($('#feedback_text').val() != '') {
        var values = {'message': $("#feedback_text").val()};
        $.ajax({
            type: "POST",
            url: "test2.aspx/ReceiveFeedback",
            data: values,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            processData: false ,
            success: function (data) {
                alert(data);
            }
        });
    }
}

Regards
   
Comments
Alireza_1362 31-May-13 2:13am
   
Thanks for answering ,after change my code according to your code ,I got this error:
{"Message":"InvalidJSONprimitive:object.","StackTrace"
Alireza_1362 31-May-13 4:04am
   
I found the problem ,so with a little changes should be :
if ($('#feedback_text').val() != '') {
var values = { 'message': $("#feedback_text").val() };
$.ajax({
type: "POST",
url: "test2.aspx/ReceiveFeedback",
data: JSON.stringify(values),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: false,
success: function (data) {
document.write(data);
}
});
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,153
Richard MacCutchan 1,804
phil.o 1,270
Patrice T 1,217
MadMyche 1,150



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100