Jump to content


Photo

Form processing issue

ajax jquery php form processing

  • Please log in to reply
1 reply to this topic

#1 swarm

swarm

    Newbie

  • New Members
  • Pip
  • 1 posts

Posted 13 May 2013 - 08:14 AM

Topic: custom jquery/ajax form in a sidebar template page
The website

Hi everyone,
I made a custom form in a sidebar template page – a plugin is not an option. I got the validation working but the processing runs foul. Next I will explain in more detail what I did.

Let me start off by saying: I am noob (and that’s probably stretching it). My problem – in short – is that a contact form validated with the jquery validation plugin, and submitted through ajax does not end up in my mailbox. And yes, I have a form processor php scrip attached but something goes wrong. But I don’t know what.

Now I have been searching the internets for an answer. Of course I don’t thoroughly understand the javascript and php stuff. None the less I did put the necessary scripts together in accordance with the many explanations that I have read.

My own guess
Before I will show you the custom scripts I want to address what I think is going foul. I made a valid html form. I used the jquery validation plugin to use the validate function on the various fields. And I added some custom jquery to tell the validation plugin exactly what fields are required. On top of that I added ajax, via the jquery form plugin, so that the form doesn’t reload upon submittal.

Now the validation works – see for yourself here. And as soon as all fields are filled out correctly, and I press submit ajax kicks in because I see the button value change as intended. After a short load – sending sequence – the button changes to ‘message send’. But I receive no email. And I have checked my spam folder: it’s empty. In previous tests – with a different script – I did receive emails with the contact form values (but there were other issues).

I am using this contact form in a WordPress template. Perhaps it is the php processor? But I can’t see what’s wrong with that file.

Also in Firebug, under ‘console’ I see a GET string with the form values after submittal.

My question is. Can someone take a look at the form (because I think the post action might be wrong, the form processor is located in the template file), the custom jquery script and the php script? Plus after the form is successfully submitted, via ajax, I would like the form to reset, to clear all fields; how would I do that?

Btw I read somewhere I can use a WordPress function to add the admin e-mailaddress in the php form processor – where you would normally put down the receivers emailaddress. Is this true? And how would I do this?

Any help is seriously appreciated. Thank you for your time.

You can check the script and code over at Pastebin:
 

Sidebar template page containing the htlm form

http://pastebin.com/0Ucn306n

 

Custom jquery form validation script

http://pastebin.com/xxPdV7eL

 

Php form processor

http://pastebin.com/1LKVPx2v

 



#2 dalecosp

dalecosp

    Advanced Member

  • Members
  • PipPipPip
  • 307 posts
  • LocationJoplin, MO

Posted 17 May 2013 - 09:39 AM

Your first and second Pastebin links both go to the sidebar template; neither links to the jQuery script.

What does your PHP script send as a response to the Ajax ... "ok", or "failed"?
"God doesn't play dice" --- Albert Einstein
"Perl is hardly a paragon of beautiful syntax." --- Weedpacket




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com