Jump to content

AJAX form submittal?


ShootingBlanks

Recommended Posts

Hello - I'm still very much new to AJAX and jQuery.  I'm pretty proficient in PHP.  Anyway, what I'm trying to do (wildly unsuccessfully) is this...

 

A user clicks a link, and a little popup window appears (using jQuery's thickbox - http://jquery.com/demo/thickbox/).  In that popup window is just one text input box (in a form named "form") and a submit button.  That all works fine.  But now I need to get that text input submitted to a mysql database.

 

I've done countless applications using only PHP to submit forms to mysql databases, so I'm quite sure that my mysql code is correct (because it's so simple).  But I'm not sure if my methods need to change (since I am kind of using jQuery/AJAX now), because the data is not submitting.  I'm not getting errors, per se, but it's just not submitting.  Also, after the form is submitted successfully I'd ideally like the user to either:

 

A) Stay in the popup window with a message saying "thank you!" and a button to close the popup

 

OR

 

B) Be taken back to the screen where they originally clicked the link to open the popup, which would now have a "thank you for submitting!" type message.

 

I can't get that to happen either.  Basically when I click "submit", the page changes to the popup window (but in a full screen now - like, it just goes to that page in a full browser window), and nothing gets submitted.  Here's what my <form> tag is (this is probably wrong):

<form action="pop_add.php?height=250&width=350&modal=true" class="thickbox" method="POST" name="form">

 

In the above, "pop_add.php" is the page that contains all the popup code (the HTML form, PHP/MySQL submittal code, etc).

 

Also, in the <head> of that same page I put the following alert (for testing), and I'm getting the results that I expect with that:

<script type="text/javascript">
$("form.thickbox").submit(function()
{

alert("beep: " + this.action);
var t = this.title || this.name || null;
var g = this.rel || false;
TB_show(t,this.action,g);
this.blur();
return true;
});
</script>

 

(alerts "beep: pop_add.php?height=250&width=350&modal=true")

 

Sorry for the long post, but I wanted to be detailed.  I'll shut up now, but if anyone can help that would be greatly appreciated!!!  :D

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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