Jump to content

Submit a form using ajax?


TheEddy

Recommended Posts

since you are using prototype i would do an onclick on the submit button...

 

and then write your function in JS like this

 

function submitit(formID)
{	
var url = "formsubmit.php";
var pars= Form.serialize(formID);

$('TransMsgDisplay').innerHTML='<img src="../templates/admin/img/indicator.gif" align="center">';
var myAjax = new Ajax.Request(
url,
{
	method: 'post',
	parameters: pars,
	onComplete: processGetLogin
});
}

function processGetLogin(originalRequest)
{
var responseTextTrim=trim(originalRequest.responseText);   

if(responseTextTrim == 1)
{
	window.location.href="index.php";
}
else
{
	$('TransMsgDisplay').innerHTML=responseTextTrim;		
}
							   
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.