I want to send two things to my ajax file. The first one is a formular (method POST) and the second is a simple string.
I can send the form like this :
$.post('ajaxDialog.php', $('#sol').serialize(),function(responseObject,ioArgs) ...
And it works but if I try to send two things like that :
$.post('ajaxDialog.php', {$('#sol').serialize(),simpleString},function(responseObject,ioArgs)
I have an error. So I tried to pass $('#sol').serialize()
into an array :
var arrayForm = $('#sol').serialize();
I can't get the values of my form with $_POST['fieldName']
with this method. How should I do ?
Thanks !
serialize
returns a url encoded query string, in the format: "key=val&anotherkey=anotherval"
To append to it, just add your new key value pair, seperated by an ambersand &
:
$.post('ajaxDialog.php',
$('#sol').serialize()+"&somestring="+simpleString,
function(responseObject,ioArgs){});