1

This question is with reference to my another question Auto complete not working. That problem is still there in my code but I thought of doing this other way. I am thinking of calling my webservice from another javascript function and pass the value returned from the service to this autocomplete function as when I try to pass some dummy values to this jquery function its running fine. i am not sure y its is not calling my webservice.

Though now i have written another function to call my service and get the request -

        function SendRequest() 
    {
    debugger;
        SearchIssues.GetServerResponse(document.getElementById('ctl00_ContentPlaceHolder1_txtIssueNo').value, OnComplete, OnError, OnTimeOut);
    }
    function OnComplete(arg)
    {
        alert(arg);
    }
    function OnTimeOut(arg)
    {
        alert("timeOut has occured");
    }
    function OnError(arg)
    {
        alert("error has occured: " + arg._message);
    }

In the script manager tage I have added the reference of my webservice -

<asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="~/SearchIssues.asmx" />
        </Services>
    </asp:ScriptManager>

I have updated my autocomplete function as -

 $(function() {
   debugger;
        $(".tb").autocomplete({
            source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]  });});

Here I have passed dummy data in source which is working fine.

the signature of my webservice is as -

    [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<string> GetCompletionList(string prefixText)
        {....
}

But its still not calling my webservice and is returning some javascript error as -

SearchIssues is undefined

Please Help Thanks

enter image description here

Community
  • 1
  • 1
akhil
  • 1,202
  • 3
  • 21
  • 43

2 Answers2

0

1> I think while calling you should have full namespace

 NameSpace.SearchIssues.GetServerResponse(document.getElementById('ctl00_ContentPlaceHolder1_txtIssueNo').value, OnComplete, OnError, OnTimeOut)

2> Your service class must have [ScriptService] attribute.

3> Test your relative URL for the service

"~/SearchIssues.asmx"

Anand
  • 14,545
  • 8
  • 32
  • 44
0

this worked for me

 [WebMethod]
            public static Array GetCompletionList(string code)
    {
    .....your code
    }


 $.ajax({
                type: "POST",
                url: "CompletionList.aspx/GetCompletionList",
                data: '{"code1":"' +code1 + '"}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (c2) {
                   ....your code
                    });

});
NG.
  • 5,695
  • 2
  • 19
  • 30