Dxtr Dxtr - 1 year ago 66
jQuery Question

submit Form and String using Ajax

How to submit both a Form and a String using Ajax

I tried this but didn't work, As I can't get

in PHP page :

type: 'POST',
url: 'operations.php?r=togreen',
data: { $(this).serialize(),
'foo': 'bar'},
success: function(msg){
error: function(){
return false; // prevent form from submitting

Answer Source

Your data property should look like this :

data : {
    foo: 'bar',
    otherprop: 'foo'


data : $(this).serialize()+"&foo=bar"

The serialize function create a string creates a text string in standard URL-encoded notation.

Your code is producing an invalid object since you don't provide a value with your first key (which is the text string).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download