Tutorial :why jquery can't return string/text?



Question:

default.aspx

<button id="getGrouper">GetGroupers</button>     <script type="text/javascript">          $(document).ready(function () {              $("#getGrouper").click(function () {                  $.ajax({                      type: "post",                      url: "Groupers.aspx/groupers",                      data: "{pid:25}",                      dataType: "text",                      success: function (data) { alert(data); },                      error: function (err) { alert("err:" + err); }                  });                  return false;              });          });      </script>    groupers.aspx.cs    [WebMethod]  public static string groupers(        int project_id)      {         string employees = "";        foreach (string s in ids.Split(','))                          {                              u = user.getUserbyUid(Convert.ToInt32(s));                                employees += "<a class=\"reply_notify_delete\" href =showuser.aspx?uid=" + u.Uid + "&pid=" + p.Pid + ">" + u.userName + "</a>  ";                          }      return employees;        }  

want to get groupers by a project_id

i want to get string type ,then append it, but i debug the code , it doesn't work , no response , and i set breakpoin , it doesn't go into "groupers" static Method , why ?


Solution:1

Where you have

"{pid:25}",  dataType: "text",  

change it to

'{"project_id":25}',  dataType: "json",   

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »