Click here to Skip to main content
13,148,549 members (59,718 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi
I have method in .cs file like below,

[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 17-Sep-12 21:17pm
abc_fm352
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?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hello,

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

dataType: "text"

dataType: "JSON"


you can find more about datatype at jQuery Ajax[^]
  Permalink  
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Try passing parameters like below,

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


(or)

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.
  Permalink  

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


Advertise | Privacy |
Web04 | 2.8.170924.2 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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