468,483 Members | 2,603 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,483 developers. It's quick & easy.

Ajax function also loading HTML /JavaScript Code

Soniad
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
4 2214
jhardman
3,405 Expert 2GB
Show the code where you think the problem lies - maybe the ajax function.

Jared
Dec 18 '10 #2
Soniad
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
johny10151981
1,059 1GB
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
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.

Similar topics

15 posts views Thread by Matt Kruse | last post: by
2 posts views Thread by www.gerardvignes.com | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.