Jump to content

Recommended Posts

Hello All,

 

I believe this is ajax (sorry if it is not)

 

I am trying to save without refreshing the page.

 

when you press the save button it runs gets all the values using getElementById

and then sends it to another forum - see code below.

 

There is quite a lot to explain please stick with it as you might be able to help me....

 

var membersave			= '../script/member_save.php?id=';
function MEMBER_Save() {
var id = document.getElementById('mem_id').value;
var about = document.getElementById('mem_about').value;
var firstname = document.getElementById('mem_firstname').value;
var lastname = document.getElementById('mem_lastname').value;
var email	= document.getElementById('mem_email').value;
var username = document.getElementById('mem_username').value;
var pass	 = document.getElementById('mem_password').value;
var repass  = document.getElementById('mem_repassword').value;
var day	= document.getElementById('mem_day').value;
var month	= document.getElementById('mem_month').value;
var year	= document.getElementById('mem_year').value;

var resetpass = "off";
if(document.member_editform.mem_reset_pass.checked == true){
	resetpass = "on";
}else{
	resetpass = "off";
}	

var resetimg = "off";
if(document.member_editform.mem_reset_image.checked == true){
	resetimg = "on";
}else{
	resetimg = "off";
}

var admin = "off";
if(document.member_editform.mem_admin.checked == true){
	admin = "on";
}else{
	admin = "off";
}

if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
}else{// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState!=4 || xmlhttp.status!=200){
		    document.getElementById("mem_saving").innerHTML="<img src="+LoadImage+">";
			setTimeout('errorloading(\'mem_saving\')',5000);
		}
	  if (xmlhttp.readyState==4 && xmlhttp.status==200){
		document.getElementById("mem_saving").innerHTML="";
	    var reply = xmlhttp.responseText;
		MEMBER_Reload(id,reply);
	    }
	  }
	xmlhttp.open("GET",membersave+id+"&about="+about+"&firstname="+firstname+"&lastname="+lastname+"&email="+email+"&username="+username+"&pass="+pass+"&repass="+repass+"&resetpass="+resetpass+"&day="+day+"&month="+month+"&year="+year+"&resetimg="+resetimg+"&admin="+admin+"&type=edit",true);
	xmlhttp.send();
}

 

Now the above seems to work fine on my computer but does not work at all on the online server the loading bar just keeps going around and around.

 

it is also rava strange as i use nearly the same code to save another thing - and this works.....

 

I have worked out that the problem seems to be caused by this line:

xmlhttp.open("GET",membersave+id+"&about="+about+"&firstname="+firstname+"&lastname="+lastname+"&email="+email+"&username="+username+"&pass="+pass+"&repass="+repass+"&resetpass="+resetpass+"&day="+day+"&month="+month+"&year="+year+"&resetimg="+resetimg+"&admin="+admin+"&type=edit",true);

 

if i remove all the other variables and text - it works (obviously this is not very useful as now nothing is being passed to the other page to save)

xmlhttp.open("GET",membersave+id,true);

 

If you have any ideas please let me know.

If there is anymore information you need/want please let me know.

 

Thank you in advance.

 

Eli

 

Link to comment
https://forums.phpfreaks.com/topic/219493-saving-form/
Share on other sites

I have found away around it. NOT A FIX.

 

The problem seems to be caused by the 'about' variable being passed in the xmlhttp.open

i do not know if this is as there is a lot of information and there is a 'limit' on the about of text that can be sent though one variable.

 

So the way around it was to remove the about variable...

 

So as i said its NOT a fix as i know can not update the about information but i shall just leave it....

 

 

Link to comment
https://forums.phpfreaks.com/topic/219493-saving-form/#findComment-1138628
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.