Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.18/5 (3 votes)
See more:
I have a small webservice and a webmethod to perform autocomplete with textbox

All i have done is change build with 2.0 rather than 3.5..

Also i have got error in XMLHttpRequest as "object XMLHttpRequest".
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"  runat="server">
    <title>AutoComplete Box with jQuery</title>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css"
        rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            SearchText();
        });
        function SearchText() {
     
            $(".autosuggest").autocomplete({

                source: function (request, response) {
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "WebService.asmx/Mydata",
                        data: "{'username':'" + request.term + "'}",
                        dataType: "json",
                        success: function (data) {
                            response(data.d);
                        },
                        error: function (result) {
                            alert(result);
                        }
                    });
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1"  runat="server">
    <div class="demo">
        <div class="ui-widget">
            <label for="tbAuto">
                Enter UserName:
            </label>
            <input type="text" id="txtSearch" class="autosuggest" />
        </div>
    </form>
</body>
</html></div>
Posted
Updated 4-May-15 20:16pm
v4
Comments
Sergey Alexandrovich Kryukov 5-May-15 1:08am    
Do you mean JSON? "Does not work" is not informative.
—SA
HimenDev 5-May-15 1:17am    
Yes its Json, I have this code for autocomplete action for textbox, this is simply works if i open property pages and set build option to framework 3.5 rather than 2.0
but i want this to be worked in asp.net framework 2.0
i got Error in below setion :
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(request.term);
alert(XMLHttpRequest);
alert(textStatus);
}

this XMLHttpRequest alert is showing me "object XMLHttpRequest" error.
and my reqest is not even sent to webservice method(my method is not calling).
i hope this helps you to solve my issue.
HimenDev 5-May-15 1:20am    
Just forget about calling mentioned method, just make it work that it can call any webmethod.

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