Help me to solve this AJAX problem

Status
Not open for further replies.

vipul

Broken In
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..
 

kalpik

In Pursuit of "Happyness"
Umm.. i have VERY little knowledge of AJAX so dunno if i would be able to help you.. But it could help if you would post some more code :)
 
OP
V

vipul

Broken In
kalpik said:
Umm.. i have VERY little knowledge of AJAX so dunno if i would be able to help you.. But it could help if you would post some more code :)

this is the AJAX.js file which going to make request:
Code:
var imagePath="../../Common/Images/Icons/bar.gif";
	var http_request = false;
	var resid;
	var lid;
    
    function makeRequest(url,param,type,loading,result)
    //makeRequest("*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 response

just
response.write("<script>alert('Hello')</script>")

but it prints <script>alert('Hello')</script> in given DIV not the script itself

Thanks
 

kalpik

In Pursuit of "Happyness"
The document.getElementById() takes in a string as a paramater..
So it should be document.getElementById("resid").innerHTML='';
Notice the quotes?
 
OP
V

vipul

Broken In
kalpik said:
The document.getElementById() takes in a string as a paramater..
So it should be document.getElementById("resid").innerHTML='';
Notice the quotes?

Yeah........ i done it...................

:D :D :D

i had just used script.aculo.us

its gr8 man........ it works 4 me...................


btw

Thanks..
 
Status
Not open for further replies.
Top Bottom