Ajax function also loading HTML /JavaScript Code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Soniad
    New Member
    • Jan 2009
    • 66

    Ajax function also loading HTML /JavaScript Code

    Hello,

    I am using ajax to get details from DB.The page where I have written DB queries has include files containing and JavaScript variables defined in it.After fetching the required data I wrtite it Using
    Code:
    Response.Write()
    Statement.
    So,In my ajax function,It not only gets written Output but also the other contents of those include pages.
    And I need only the written Ouput of that page.
    I tried "innerText" and "innerHTML";but ,no desired result.
    Any Suggestion Please.

    Regards,
    "D"
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Show the code where you think the problem lies - maybe the ajax function.

    Jared

    Comment

    • Soniad
      New Member
      • Jan 2009
      • 66

      #3
      Hello,

      Ajax Function :

      Code:
      function FnGetFileList()
      {
          xmlHTTP4=null;
          try{xmlHTTP4 = new XMLHttpRequest();}catch(e){try{xmlHTTP4 = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlHTTP4 = new ActiveXObject("Microsoft.XMLHTTP");}catch(e){alert("Your browser dont support Ajax..");return false;}}}
         
          var url,returnval; 
          url = "Test.asp";
          alert(url);
      	
           xmlHTTP4.onreadystatechange = function()
          {
          if (xmlHTTP4.readyState==4)
          {
          returnval = xmlHTTP4.responseText;
      	document.getElementById("DivList").innerText = xmlHTTP4.responseText;
          alert("Test :" + document.getElementById("DivList").innerText);
          }
          }
          xmlHTTP4.open("GET",url,true);
          xmlHTTP4.send(null);
      }
      Code:
      	
      	<!--Display File List-->		
      		<div id="DivList" style="display:;">			
      		</div>
      Test.asp :
      Code:
      <!-- #include virtual = "Connection.asp" -->
      <%
       'Query Here
       Respose.Write(OutPut)
       
      %>
      Regards,
      "D"

      Comment

      • johny10151981
        Top Contributor
        • Jan 2010
        • 1059

        #4
        eval is your solution. But I am not sure how to use it. Cause I use JQuery function to make asynchronous call. Which fix all the issues

        Comment

        • Soniad
          New Member
          • Jan 2009
          • 66

          #5
          Hi,

          Instead of innerText,inner HTML works :
          Code:
            document.getElementById("DivList").innerHTML= xmlHTTP4.responseText;
          Regards,
          "D"

          Comment

          Working...