Return data to Ajax from PHP file

I have a form that submits data through AJAX to a PHP file.  (register-code.php) (www.celsyouth.cenational.org/register/index.php) The PHP file saves the data to a mysql database.  Once the PHP file is completed, I'd like to post an ID number back to the AJAX call to send it to another PHP file where the user will have the option of paying by credit card.  Here's the AJAX code...

		
submitHandler: function(form) {
            var dataString = $(form).serialize();
                    $(form).ajaxSubmit({
                            url:"register-code.php",
                            type:"post",
                            data: dataString,
                            cache: false,
                            success: function(data){
 			    alert(data);
                            window.location.href = 'registrationComplete.php?ID=$var_id'; 
                                 
                            },
							error: function( jqXHR, textStatus, errorThrown){
								alert("Error:" +textStatus);
							}
                    });
            },   

Open in new window


I can 'echo' the data back to the AJAX function, but how do I pass the ID into registrationComplete.php?

Thanks for all the help in advance.

Steve
LVL 2
stkoontzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
success: function(data){
     if(data.status) window.location.href = 'registrationComplete.php?ID=' + data.id; 

Open in new window


and in register-code.php you've at the end if the registration is complete:
echo '{"status":true,"id":"' . $id . '"}';
?>

Open in new window


but why not storing this ID in the session, it's more secure?
$_SESSION['id'] = $id;
and just return status (true or false)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stkoontzAuthor Commented:
Thanks  leakim971.  Sometimes the simplest solution is the best.  The session variable is working great.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.