Jump to content

Posting forms to Ajax script


gerkintrigg

Recommended Posts

Hello.

 

I think I have worked out where my problem lies, but have no clue how to fix it.

 

I'm posting the first name, surname and email to a newsletter signup script I found online. The original script only used the email address, but I wanted to make it a little more dynamic (a bit like aweber in that it can accept [fname] and replace it with the name from the database). Everything works except actually inserting the fname and sname variables into the database. (I was testing it using the SQL back end, originally).

 

I have tracked the issue to a Javascript snippet which originally said this:

 

data: 'email=' + $('#email').val(), // data to post

 

Thinking logically (or not), i changed it to this:

data: 'email=' + $('#email').val()+
	'fname=' + $('#fname').val()+
	'sname=' + $('#sname').val(), // data to post

 

This was initially just to prove to myself that the data is there and being passed to the script... it is, but it currently outputs like this:

 

[email protected]=firstnamesname=surname

 

Could someone please let me know what I'm doing wrong. I'm fine with PHP, but to say that I "muddle through" the javascript aspect is probably about right.

Link to comment
https://forums.phpfreaks.com/topic/259047-posting-forms-to-ajax-script/
Share on other sites

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.