Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    May 2013
    Posts
    24
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Turning a form into an ajax push using JQuery

    Hi,

    I would like to transform the form below into an ajax push where the visitor only have to enter the name and email and click submit without showing the script's outputs. This is some improvements that i will be made on Ashley Turner website.

    Code:
    <form action="https://bd101.infusionsoft.com/app/form/process/028e37bef753ffd5cf969c99ba21c1c2" method="POST" accept-charset="UTF-8" id="formmain" class="top-form">
    <input type="hidden" name="inf_form_xid" value="c21c8a5e43fd2868a222dc6937fbf3ed" />
    <input type="hidden" name="inf_form_name" value="Sign up for newsletter" />
    <input type="hidden" name="infusionsoft_version" value="1.29.10.21" />
    <input name="que" type="hidden" value="DBBhhx8IAv9Nsk8Lj0mpTHrrY0+IiLAOCX5C28sW5fMiXpi07AnMT/SScDKNN2IPO2UBgBys7CV560+kCXiap+AdvB2jigNrmqF6gUZ+VE1WFrS39jWtqzkwXmdsZCGKYNqll1Zjgehc21xJhLsMrEViVJV/PAAiDyLt8f4wIP4=" />
    <input name="cam" type="hidden" value="/br/c/br1" />
    <input type="text" name="inf_field_FirstName" id="da_name" required value="">
    <input type="text" name="inf_field_Email" id="da_email" required value="">
    <input type="submit" class="button" name="submit" value="Submit">
    </form>
    Thanks

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Is bd101.infusionsoft.com your domain and you have access to edit the file referenced by the action URL? If so, then try adding response header "204 No Content".

    If not (which I think is the case), then just submit the form to a hidden iframe.
    Code:
    <form action="https://bd101.infusionsoft.com/app/form/process/028e37bef753ffd5cf969c99ba21c1c2" target="submitFrame" method="POST" accept-charset="UTF-8" id="formmain" class="top-form">
    ...
    </form>
    <iframe name="submitFrame" src="about:blank" style="display:none;"></iframe>

  • #3
    New Coder
    Join Date
    May 2013
    Posts
    24
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Doesn't work, at all. It breaks the iframe so it can't be done with an iframe

  • #4
    New Coder
    Join Date
    May 2013
    Posts
    24
    Thanks
    5
    Thanked 0 Times in 0 Posts

    (New to Ajax)

    I want in this scructure if possible
    This has a plus - No notification in the browser

    Code:
    <script src="jquery.min.js"></script>
    <script>
    // This will send the content of the variable "email" to the script without showing the script's outputs
    function sendEmail() {
      var email = $('[name=email]').val();
      $.ajax({
        url : 'https://bd101.infusionsoft.com/app/form/process/028e37bef753ffd5cf969c99ba21c1c2',
        type: "POST",
        data: {email:email},
        success: function() {}
      });
    }
    
    $('[name=submit]').submit(function() {
       sendEmail();
       return false;  // this prevents the browser submit (which would show the resulting HTML)
    });
    </script>
    <a href="#" onclick=sendEmail();>1</a>
    Credits for the code goes to devnull69
    Last edited by Electrify; 04-16-2014 at 07:32 PM.

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Then bd101.infusionsoft.com has a frame-breaker script to prevent their site from being framed.

    Do they allow CORS requests?

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Quote Originally Posted by Electrify View Post
    I want in this scructure if possible
    This has a plus - No notification in the browser

    Code:
    <script src="jquery.min.js"></script>
    <script>
    // This will send the content of the variable "email" to the script without showing the script's outputs
    function sendEmail() {
      var email = $('[name=email]').val();
      $.ajax({
        url : 'https://bd101.infusionsoft.com/app/form/process/028e37bef753ffd5cf969c99ba21c1c2',
        type: "POST",
        data: {email:email},
        success: function() {}
      });
    }
    
    $('[name=submit]').submit(function() {
       sendEmail();
       return false;  // this prevents the browser submit (which would show the resulting HTML)
    });
    </script>
    <a href="#" onclick=sendEmail();>1</a>
    Credits for the code goes to devnull69
    AJAX requests are subject to Same-Origin Policy. A page can only make AJAX requests to the domain it was loaded from, and not to other domains. Unless the other site allows CORS requests.

  • #7
    New Coder
    Join Date
    May 2013
    Posts
    24
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Try and reply back, sure it's simple standing in your point of view.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •