Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Develop Branch Forms plugin problem

edited April 2015 in Bug Reports
Using the latest Git pull of the develop branch and Forms plugin module.

I've created a form in Fuel and set "Form Display" to auto, a couple of basic fields, javascript submit and some "after submit" text. I've added the form to a page using {form('myform')}.

If I fill in the form and click submit, I see the "sending..." text and the message gets sent but instead of seeing my nice "after submit" text, I get an embedded version of the whole page (header, page text & footer) along with the "after submit" text.

Have I not configured something correctly?

Cheers

Comments

  • edited 3:23PM
    That sounds like it's hitting the Forms controller process method and it's not honoring the is_ajax() method. Are you able to debug the result in that controller?
  • yeah, I was thinking ajax. I'll take a look, thanks for the pointer...
  • It seems that the is_ajax() call is returning false when it should be true (if I hard code true, it works). I'm guessing the HTTP_X_REQUESTED_WITH = XMLHttpRequest is not being set somewhere...

    Where would that be?
  • OK. It's handled by JQuery Forms in the forms.js script.

    The submitSuccess function gets called but instead of displaying the text, it displays the whole page.

    This seems to to be a Firefox only problem, Chrome seems to work.
  • I've got it down to forms.js::$(form).ajaxSubmit(formOptions);

    jquery.forms::ajaxSubmit(formOptions) is failing to pass X_REQUESTED_WITH properly.

    Annoyingly, this currently seems to be specific to Linux Firefox only (v37.0.2 on my rig). Historically though, there seems to be combinations of js and jquery that cause X_REQUESTED_WITH to disappear such that we can't rely on that header to tell us if it's an ajax call or not.
  • edited April 2015
    I ran into an is_ajax() related issue on a MediaTemple Grid server using CGI a while back. It appeared that the server was caching the pages (thus it was trickier to diagnose and replicate) and subsequently not even returning the proper AJAX headers in some cases. To test it out, I did the following:

    1) Created a test ajax page with just HTML:
    <html> <head> <title>TEST</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> </head> <body> <h1>This following infomation is AJAXed in and should display the "[HTTP_X_REQUESTED_WITH] => XMLHttpRequest" information:</h1> <div id="ajaxed"></div> $.ajaxSetup ({ // Disable caching of AJAX responses cache: false }); <script type="text/javascript"> // run a simple ajax request... doesn't matter to what page $(function(){ $('#ajaxed').load('test_ajax.php'); }) </script> </body> </html>

    2) The "test_ajax.php" page just outputs the contents of the server variable:
    <p>Below is the output:</p> <?php echo '<pre>'; print_r($_SERVER); echo '</pre>'; ?>

    3) Then as a check to test a non-AJAX call for comparison:
    <h1>The following information should <u>NOT</u> display the "[HTTP_X_REQUESTED_WITH] => XMLHttpRequest" information:</h1> <p>This is just a simple page with the following PHP code:</p> <code> <p>Below is the output:</p> <?php echo '<pre>'; print_r($_SERVER); echo '</pre>'; ?>
Sign In or Register to comment.