Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello I want to access my WCF service method inside jquery GET method
Where WCF service in one solution and
My Application in another solution

My method is following below
$("#btnStartChat").click(function () {
               debugger;
               //var U = "/Commons/Chat/ChatroomHome.aspx/CheckUser";
               var U = "http://localhost:8004/HRMSRestService.svc/CheckUser";
               var name = $("#txtNickName").val();
               $.ajax({
                   url: U,
                   data:  {Name:name},
                   type: "GET",
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (data) {
                       alert('ok');
                       if ($("#txtNickName").val().length > 0) {
                           myHub.server.connect($("#txtNickName").val());
                       }
                       else {
                           alert("Please enter name");
                       }
                   },
                   error: function (ex) { }
               });


           });

I could not access the service method it means it's not firing is any issue
Tell me why?
And one more thing I have tried it in code behind also where is uncommented but could get any success.
Posted
Comments
Do you see any error in Firebug console window in Firefox?
Deeps1414 6-Dec-13 7:44am    
Yes I am checking with debugger it's firing but debugger is not coming to service method any issues
No, it will not go inside Service method. But you can check what is the data transferred between the page and WCF call in NET tab.

Also see after the call if there are any errors showing on Console tab.

See you did one more mistake passing data in jquery method
and use your commented path where it will access webmethod there.
I have just copied your code tried it should like

$("#btnStartChat").click(function () {
              //debugger;
           var U= "ChatroomHome.aspx/CheckUser";
           var name = $("#txtNickName").val();
              $.ajax({
                  url: U,
                  data: "{Name: '" + name + "' }",
                  type: "POST",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function (data) {
                       if(data.length>0) {
                      //do your task
                       }
                      else {
                          alert("Please enter name");
                      }
                  },
                  error: function (ex) { }
              });
          });

thanks
 
Share this answer
 
v2
Comments
Deeps1414 6-Dec-13 8:09am    
Thanks sankarsan for your nice trick
 
Share this answer
 
Comments
Deeps1414 17-Jun-14 2:07am    
I have 2 window forms. And how can set the 2nd form in a particular location of 1st form?

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