views:

133

answers:

2

I'm posting from a form to a URL like so:

$.post('?class=articles&method=submit', $(this).serialize(), function(msg)
{
    alert(msg);
    $(msg.html).hide().insertBefore('#addCommentContainer').slideDown();
    $('#body').val('');
},'json');

And in the 'submit' method the last line is:

print json_encode( array('html'=>$content) );

Yet I'm not even getting to the alert portion in the jQuery.

I have a feeling it is because the 'submit' method is in a class file that is part of a template system (similar to phpBB). I know that creating a seperate .php file for submitting would work, but was curious if there was any other way.

A: 

try using the $.ajax method, instead of the shorthand. I believe the problem is that you're using the POST shortcut method, while specifying GET variables appended to the URL.

let me know if this helps, if not, We'll be able to help you :-)

I'm on vacation, on a netbook, so I can't exactly write a whole new method at the moment.

Bob Gregor
+1  A: 

Looks like you don't even have a specific url:

$.post('?class=articles&method=submit', $(this).serialize(), function(msg)

Should be I think

$.post('thePlaceIsubmitTo.php?class=articles&method=submit', $(this).serialize(), function(msg)

I believe that the serialize data will be appended to the url with and &, Be sure that this refers to the form tag

Gutzofter