Click here to Skip to main content
11,581,397 members (61,490 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax jQuery
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
Edited 17-Sep-12 21:20pm
v2
Comments
Zoltán Zörgő at 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 at 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ő at 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/ at 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ő at 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
0 OriginalGriff 340
1 Sergey Alexandrovich Kryukov 160
2 virusstorm 114
3 Frankie-C 105
4 RyanDev 84
0 OriginalGriff 1,273
1 Sergey Alexandrovich Kryukov 895
2 Abhinav S 597
3 F-ES Sitecore 500
4 Suvendu Shekhar Giri 433


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2015
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