1

I have a table created with PHP/MySQL results, http://www.fsma.co.uk/help/table.jpg.

When the user clicks the resend confirmation button, I have a jQuery script that runs a PHP script to send the email to that customer.

What I need is for that button to then change to text and give the returned mesage from the PHPscript, or for a new row to be added underneath to show the returned message.

I had it working, but no matter which button you clicked it used the same row. However, due to playing around with so many ideas, I no longer have that code.

2
  • Seems to be back now, but it wasn't there 45 secs ago. Commented Feb 1, 2013 at 15:31
  • 1
    Use the jQuery.post function: api.jquery.com/jQuery.post The functions callback is the echoed content from your php function. Commented Feb 1, 2013 at 15:33

1 Answer 1

1

Something like that:

$(".buttonClass").click(function(event) {
    event.preventDefault();
    $.post(url, data, function(response) {
        // hide the clicked button
        $(this).hide(); 

        // insert content from the called php function after the button
        $(this).after(response);
    });
});

Your php function has to echo the content you want to display instead of the button.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, but it just sends the form and goes to hte next page as normal.. sorry im sure its something simple, i just have no clue ! 8-(
I've updated my answer. eventPrevault() will prevent the default action to happen.
add "return false;" before the last closing });
thanks again but it still does the same... i have pasted the code for my form, and the Jquery here (pastebin.com/aPw1zgv2)
Does the jQuery.click() get triggered? What if you put an alert('test'); directly above the event.preventDefault()
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.