Ajax return string links not working

Posted by Andreas Lympouras on Stack Overflow See other posts from Stack Overflow or by Andreas Lympouras
Published on 2012-11-04T16:32:23Z Indexed on 2012/11/04 17:00 UTC
Read the original article Hit count: 188

Filed under:
|
|

I have this ajax function:

function getSearchResults(e) {

            var searchString = e.value;

            /*var x = e.keyCode;
            var searchString = String.fromCharCode(x);*/

            if (searchString == "") {
                document.getElementById("results").innerHTML = "";
                return;
            }
            var xmlhttp;
            if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            }
            else {// code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    document.getElementById("results").innerHTML = xmlhttp.responseText;
                }
            }

            xmlhttp.open("GET", "<%=Page.ResolveUrl("~/template/searchHelper.aspx?searchString=")%>"+searchString, true);

            xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); //solve any AJAX caching problem(not refreshing)
            xmlhttp.send();
        }

and here is when I call it:

<input class="text-input" value="SEARCH"  id="searchbox" onkeyup="javascript:getSearchResults(this);" maxlength="50" runat="server" />

and all my links in the searchHelper.aspx file(which retruns them as a string) are like this:

<a class="item" href='../src/actors.aspx?id=77&name=dasdassss&type=a' > <span class="item">dasdassss</span></a>  

When I click this link I want my website to go to ../src/actors.aspx?id=77&name=dasdassss&type=a but nothing happens.

When I hover over the link, it also shows me where the link is about to redirect!

any help?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about html