Jump to content

Help me to solve this AJAX problem


vipullimbachiya

Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...