By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,867 Members | 1,964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,867 IT Pros & Developers. It's quick & easy.

Ajax function also loading HTML /JavaScript Code

Soniad
P: 66
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
Expand|Select|Wrap|Line Numbers
  1. 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"
Dec 18 '10 #1
Share this Question
Share on Google+
4 Replies


jhardman
Expert 2.5K+
P: 3,405
Show the code where you think the problem lies - maybe the ajax function.

Jared
Dec 18 '10 #2

Soniad
P: 66
Hello,

Ajax Function :

Expand|Select|Wrap|Line Numbers
  1. function FnGetFileList()
  2. {
  3.     xmlHTTP4=null;
  4.     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;}}}
  5.  
  6.     var url,returnval; 
  7.     url = "Test.asp";
  8.     alert(url);
  9.  
  10.      xmlHTTP4.onreadystatechange = function()
  11.     {
  12.     if (xmlHTTP4.readyState==4)
  13.     {
  14.     returnval = xmlHTTP4.responseText;
  15.     document.getElementById("DivList").innerText = xmlHTTP4.responseText;
  16.     alert("Test :" + document.getElementById("DivList").innerText);
  17.     }
  18.     }
  19.     xmlHTTP4.open("GET",url,true);
  20.     xmlHTTP4.send(null);
  21. }
Expand|Select|Wrap|Line Numbers
  1.  
  2.     <!--Display File List-->        
  3.         <div id="DivList" style="display:;">            
  4.         </div>
Test.asp :
Expand|Select|Wrap|Line Numbers
  1. <!-- #include virtual = "Connection.asp" -->
  2. <%
  3.  'Query Here
  4.  Respose.Write(OutPut)
  5.  
  6. %>
  7.  
Regards,
"D"
Dec 20 '10 #3

100+
P: 1,059
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
Dec 20 '10 #4

Soniad
P: 66
Hi,

Instead of innerText,innerHTML works :
Expand|Select|Wrap|Line Numbers
  1.   document.getElementById("DivList").innerHTML= xmlHTTP4.responseText; 
Regards,
"D"
Feb 23 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.