Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have method in .cs file like below,

C#
[WebMethod]
public static void UpdateAvlCalender(string status,string forDate)
 {
 }

And i am calling through jquery ajax  using

 $.ajax({
                 type: "Post",
                 url: "Test.aspx/UpdateAvlCalender",
                 data: { status: $("#status").val(), forDate:            $("#SelectedDate").val() },
                 contentType: "application/json; charset=utf-8",
                 dataType: "text JSON",
                 success: function(msg) {                    
                     $("#dialog-modal").dialog("destroy");
                    
                 }
                 
             });

Its not working. but if i dont pass any parameter it works fine.

Please suggest what might be the issue?

Thanks in advance.
Posted
Updated 17-Sep-12 21:20pm
v2
Comments
Zoltán Zörgő 18-Sep-12 3:22am    
And how exactly is it "not working"? Have you debugged it with Fiddler or IE9 Developer Toolbar to see what data is sent? Are you sure, that multiple data type is good for you?
abc_fm 18-Sep-12 3:33am    
Thanks Zoltan for quick reply,
yes i checked data is sent properly, but still the same issue its not calling the server side method
Zoltán Zörgő 18-Sep-12 3:43am    
Try a simpel test first (http://stackoverflow.com/questions/4205704/ajax-webmethod-help)
Be aware of ScriptService attribute!
Ankur\m/ 18-Sep-12 4:52am    
Check the datatype. Also what is the parameter that you server side method accepts?

Try passing parameters like below,

JavaScript
data: '{"status":"'+$("#status").val()+'", "forDate":"'+$("#SelectedDate").val()+'"}',


(or)

JavaScript
data: JSON.stringify({ status: $("#status").val(), forDate: $("#SelectedDate").val() }),


I remember that the first one worked for me when I had a similar issue, Hope it helps.
 
Share this answer
 
Comments
Vasanth Kumar 1-Sep-19 20:12pm    
Hi Rajeev,

I used Both your solution and Dhol's solution, nothing is working for me.
Hello,

you have a problem with datatype, you have written "text JSON" there are not such data type of json

JavaScript
dataType: "text"

JavaScript
dataType: "JSON"


you can find more about datatype at jQuery Ajax[^]
 
Share this answer
 
Comments
Zoltán Zörgő 18-Sep-12 4:27am    
But here is. Read the link you have given:
"multiple, space-separated values: As of jQuery 1.5, jQuery can convert a dataType from..." and so on

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



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