Search

Hi.

I'm trying to asynchronously submit and validate comment forms and created a new page with type set to XML and my submit event source attached. The page itself works just fine, i can call it as my form action and it is putting out all submitting event data, however, calling the page asynchronously ( jquery post ) the event source is just empty.

I'm pretty sure my post vars are correct…

the whole thing looks like this (pretty simply):

    $('form').bind('submit',function(e){
    e.preventDefault();

    var form = $(e.target),
        data = form.serialize(),        
        postVars = data + '&' + form.find('[name^=action]').attr('name') + '=submit';

    $.post('/ajaxvalidate', postVars ,function( data ){
        console.log( arguments );
        // do something
    });

});

results in postvars:

MAX_FILE_SIZE                      5242880
action[comment-submit]     submit
fields[author]                     author name
fields[blogpost]                       18
fields[e-mail]                     author@mail.net
fields[message]                    mesage, foo bar
fields[url]

so this should be fine

idea?

okay, I set this up on a different server… seems to work there. Still have no clue, why it fails on my local sever. I'll keep digging

jQuery .post will fail silently if there is an error, which will result in your empty page (I think)

Explained here

jepp, I know. It is not that i got an empty page result but the event object is empty. If I add an e.g. login event to that page, the event object shows up for that event.

ok, sorry

no props :D

HA! Got it. Damn!

Long term short: a missing trailing slash in the url causes jQuery to handle the request as a GET request, no matter how you set your ajax setup.

Damn! :D

Heh, 1 month later!

Glad you got it, useful to know too!

Yepp :D

Actually wasn't searching for a solution since it was just a test, and seemingly, setting up another project did solve the problem.

I ran accross this issue again, after setting up my ( I would say asskicking ) symphony mailform jquery plugin for a different project :D (my plugin now takes care of missing slashes)

Heh, that reminds me of an old gist I have that does a similar thing :)

This originally was my inspiration :D

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details