I am trying to post some parameters to a php page using AJAX which I also want to load on the browser as it is an editing form. I used windows.location.href to load the page but it seems it is loading a new copy of the page instead of loading the one the parameters are being posted to. How can I show the page I post the parameters to on the browser? The code I am using is:
Code:
var btnParent=checkedBtn.parentNode.parentNode;
	var trainingId=btnParent.id;
	var content=document.getElementById('Content_'+trainingId).innerHTML;
	var subject=document.getElementById('Subject_'+trainingId).innerHTML;
	var title=document.getElementById('Title_'+trainingId).innerHTML;
	var price=document.getElementById('Price_'+trainingId).innerHTML;
	var ch=document.getElementById('Ch_'+trainingId).innerHTML;
	var dates=document.getElementById('Dates_'+trainingId).innerHTML;
	//var dateArray=dates.split(',');
	var parameters="trainingSubject="+(subject)+"&trainingId="+encodeURI(trainingId)+"&trainingTitle="+encodeURI(title)+"&trainingContent="+encodeURI(content)+"&trainingPrice="+encodeURI(price)+"&trainingCh="+encodeURI(ch)+"&trainingDates="+encodeURI(dates);
    parameters.replace(/&/g, '%26');  
	var xmlhttp;
	if (window.XMLHttpRequest)
  	{
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else if (window.ActiveXObject)
  	{
  		// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else
  	{
  		alert("Your browser does not support XMLHTTP!");
  	}
	//call php script
   
    xmlhttp.onreadystatechange=function()
    {
        if(xmlhttp.readyState==4)    
        {
		}
    }
   
   xmlhttp.open("POST","editTreinamentos.php",true);      
     xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   xmlhttp.setRequestHeader("Content-length", parameters.length);
   xmlhttp.setRequestHeader("Connection", "close");    
	xmlhttp.send(parameters);
	window.location.href="editTreinamentos.php";//line to show the page editTreinamentos, which is the page I am posting parameters to
Any help on this would be much appreciated.
Thanks
Ishan