hi,

I have a gallery, upon clicking a gallery set, the page should open it's photos without refreshing, therefore i use XMLHttpRequest.

It works fine if i am display just plain text/images, but im trying to display javascript & html content.

I want to display my "smoothgallery" according to gallery set that was chosen.

Here is a link to the website:
http://www.maestro2007.co.il/index.php?mid=3

Click on an image on the right, it should open the smoothgallery on the left.

This is my request page:

function getMessageResponse(str){
	var xmlHttp;
	var divelement = document.getElementById('response'); 
	divelement.innerHTML = '<p>Loading, please be patient...</p>';
	
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		xmlHttp.overrideMimeType("text/html; charset=windows-1255"); /*TO DISPLAY HEBREW CHARACTERS*/	
	}
	catch (e){
	    // Internet Explorer
  		try{
		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");			
    	}
		catch (e){
	    	try{
		      	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				xmlHttp.setRequestHeader('Content-Type','text/html; charset=windows-1255')
        	}
			catch (e){
			  alert("Your browser does not support AJAX!");
			  return false;
			}
    	}
	}
	
	xmlHttp.onreadystatechange=function(){ //Used to set the callback function that handles request state changes.
		//alert(xmlHttp.status+' - '+xmlHttp.readyState);
		if(xmlHttp.readyState==4){	// 0 = uninitialized 1 = loading 2 = loaded 3 = interactive 4 = complete 
		  divelement.innerHTML=xmlHttp.responseText; //Returns the server response as a string.
		  //alert(xmlHttp.responseText);
		  //document.myform.message.value = '';
		}
	}

	//url=url+"&message="+str;
	var url="projects.php?mid=3";	
	url=url+"&pid="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.open("GET",url,true); //Initializes the request parameters.   / or POST data larger than 512 bytes	
	xmlHttp.send(null);	//Performs the HTTP request.
}

you mention a database, therefore you would probably want a server-side language to set up a database connection.

The DB connection is in the "projects.php" page. Which i know works fine because i put an alert and i see it retrieved the correct data from the DB.

I understand that i can't execute javascript from xmlHttp.request, therefore, what can i do instead without reload the page?

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.