AJAX to PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: AJAX to PHP

Post by manRay »

I updated the request string.

Code: Select all

 
XMLHttpRequestObject.send(fname= document.form1.fname.value & lname= document.form1.lname.value & password= document.form1.password.value & password2= document.form1.password2.value & email= document.form1.email.value & email2= document.form1.email2.value & operating= document.form1.os.value & agree= document.form1.agree.checked);
 
But dreamweaver is saying there is a syntax error. What could it be?
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: AJAX to PHP

Post by jazz090 »

u need to enclose the text with quotes and the vars with a +
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: AJAX to PHP

Post by manRay »

I did what you said and there is still a syntax error.

Code: Select all

 
XMLHttpRequestObject.send(fname=+"document.form1.elements['first'].value"&lname= +"document.form1.elements['last'].value"&password= +"document.form1.elements['pass'].value"&password2= +"document.form1.elements['pass2'].value"&email= +"document.form1.elements['mail'].value"&email2= +"document.form1.elements['mail2'].value"&operating= +"document.form1.elements['os'].value"&agree= +"document.form1.elements['agree'].checked");
 
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: AJAX to PHP

Post by jazz090 »

do not put these in quotes document.form1.elements['first'].value these are variables and not strings but the rest in quotes. also i think you should use DOM instead of refering to form objects. just give each feild an id attribute and define it in JS

Code: Select all

<input type="text" id="name_feild" />

Code: Select all

var nameFeild = document.getElementByID("name_feild")
now access it by

Code: Select all

nameFeild.value
make sure you run that code after the input tag has been specified otherwise it will be undefined at start of the script.
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: AJAX to PHP

Post by manRay »

I did what you said, although there is no error, the php page does nothing now.

Code: Select all

var fnameField= document.getElementById('first');
var lnameField= document.getElementById('last');
var passwordField= document.getElementById('pass');
var password2Field= document.getElementById('pass2')
var emailField= document.getElementById('mail');
var email2Field= document.getElementById('mail2');
var operatingField= document.getElementById('os');
var agreeField= document.getElementById('agree');
         
XMLHttpRequestObject.send("fname="+fnameField.value&"lname=" +lnameField.value&"password=" +passwordField.value&"password2=" +password2Field.value&"email=" +emailField.value&"email2=" +email2Field.value&"operating=" +agreeField.value);
Last edited by Benjamin on Sun May 10, 2009 12:40 pm, edited 1 time in total.
Reason: Changed code type from text to javascript.
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: AJAX to PHP

Post by jazz090 »

ok i just realised ow many errors your script has, give me a minute to tell you what to do, im just typing up some code
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: AJAX to PHP

Post by manRay »

I appreciate it Thanks!
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: AJAX to PHP

Post by jazz090 »

actualy its gonna take a lotta time and you know this isnt free. what i can tell you however is the fact that your ajax script is completly wrong, the method you are sending your vars could not be more wrong. also if your testing that with firefox, it would not work. i suggest you look at some tutorials in sending ajax scripts
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: AJAX to PHP

Post by manRay »

Of course this is free! Thanks for the help111
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: AJAX to PHP

Post by jazz090 »

what do you want me to write the ENTIRE script for you?
Post Reply