Jump to content

Ajax form processing


JTallis

Recommended Posts

I'm using Ajax to process a form. Code is below. It works fine, but what happens is.. the error is inside the table. So when I hide the previous form. If an error occurred, it'd populate the new div with the same kind of table, but with an error in.

 

When processing the form again with this ... new div, it refreshes the page.

 

So what I tried to do, is change the original forms HTML with the Ajax, and insert the HTML gotten from the validation (on form processing) but this never worked. It broke the whole script basically.

$(function() {     
    $("#resend").click(function() {
        
        $("#rsForm").hide();
        $("#loading").show().html('<img src="http://www.kanawhavalleyre.com/images/loading_circle.gif" />');

        $.ajax({
            type: "POST",
            url: "modules/rsactivation/rsact.main.php",
            data: {email: $("#email").val()},
            cache: false,
            success: function(html){
                $("#loading").remove();
                
                $("#msg").prepend(html);
                $("#msg").show();
            }
        });
        return false;
    });   
});

 

rsact.main.php basically has the processing in it. It returns stuff where required. You can view what goes on [url=http://"http://www.horble.com/resendactivation.php"]Here.

 

When clicking the button once, it looks fine, it works fine. Though when you click it again, it refreshes the page. #rsForm holds the original form that works, but #msg holds the new form given from rsact.main.php. As already noted, I tried to change the code to edit #rsForm and insert the output given from rsact.main.php but it never worked.

 

Do you have any ideas? Thanks

 

Link to comment
Share on other sites

Sweet. I changed it around alot. #msg is now inside the form (#rsForm). It now works. This is the new Ajax.

$(function() {     
    $("#resend").click(function() {
        
        $("#rsForm").hide();
        $("#loading").show().html('<img src="http://www.kanawhavalleyre.com/images/loading_circle.gif" />');

        $.ajax({
            type: "POST",
            url: "modules/rsactivation/rsact.main.php",
            data: {email: $("#email").val()},
            cache: false,
            success: function(html){
                $("#loading").hide();
                
                $("#rsForm").show();
                $("#msg").html(html);
            }
        });
        return false;
    });   
});

Link to comment
Share on other sites

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.