vipullimbachiya Posted January 17, 2007 Share Posted January 17, 2007 Hello friends,i had made 1 web service which returns the html containing <script>alert('hello')</script>after getting response from server i had assigned the responseText to one div's innerHTML but it not working so how can i use this script to work it out.i need it for 1 application which registers the images in dragable content, so if no way to run this script in this way then is there any way to make it??Thanks in advance..__________________ Link to comment Share on other sites More sharing options...
aspnetguy Posted January 17, 2007 Share Posted January 17, 2007 Try this element.innerHTML = eval(ajax.request.responseText) It is not working because it is passed as text not html. eval() should fix that. Link to comment Share on other sites More sharing options...
zachninme Posted January 17, 2007 Share Posted January 17, 2007 Out of curiosity, if a page returned the escape characters, when placed in the page, would it stay "escaped" or would it become HTML? Link to comment Share on other sites More sharing options...
vipullimbachiya Posted January 18, 2007 Author Share Posted January 18, 2007 Its still not workin, please give me way to work it out i am pasting my code herethis is the java script: var imagePath="../../Common/Images/Icons/bar.gif"; var http_request = false; var resid; var lid; function makeRequest(url,param,type,loading,result) //makeRequest("http://xyz.com","name=abc","POST/GET","LoadId","ResId") { resid=result; lid=loading; document.getElementById(lid).innerHTML="Loading...<br><img src='" + imagePath + "'><br>"; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE http_request = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser not support XMLHTTPRequest."); } http_request.onreadystatechange = alertContents; http_request.open(type, url); http_request.setRequestHeader("Host","localhost"); http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); http_request.send(param); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { document.getElementById(resid).innerHTML=''; document.getElementById(resid).innerHTML=http_request.responseText; document.getElementById(lid).innerHTML=""; } else { alert('There was a problem with the request.'); document.getElementById(lid).innerHTML=""; } } } and in responsejustresponse.write("<script>alert('Hello')</script>")show how to do it, is there any other way?? Link to comment Share on other sites More sharing options...
jesh Posted January 18, 2007 Share Posted January 18, 2007 Rather than trying to write javascript to the innerHTML of an element, can you do this instead? function alertContents(){ if (http_request.readyState == 4) { if (http_request.status == 200) { alert(http_request.responseText); } else { alert('There was a problem with the request.'); } }} What, other than having an alert, are you trying to do with the responseText? Link to comment Share on other sites More sharing options...
vipullimbachiya Posted January 19, 2007 Author Share Posted January 19, 2007 no no actually i have to use this script in my applicationlet me tell in detail to getting idea about:i have to take the html response from asp.net page and the content have images, now that images have to register in draggable(); function so if AJAX not allow me to add script in response then what is next approach?Thanks Link to comment Share on other sites More sharing options...
vipullimbachiya Posted January 19, 2007 Author Share Posted January 19, 2007 Yeah........ i done it................... i had just used script.aculo.usits gr8 man........ it works 4 me...................btwThanks Frnds.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now