Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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:
C#
[WebMethod]
   [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
   public static string ReceiveFeedback(string message)
   {
       string msg = "Thanks for your feedback";
       return msg;
   }
Posted
Updated 8-Nov-19 14:19pm
v2

1 solution

Hello,

Change your calling code as shown below.
JavaScript
$('#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
 
Share this answer
 
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


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900