The following is the pa开发者_运维问答rt of a script, where i sent some values to a php-file:
var order2 = $(ui.item).attr(\'id\') + \'&action2=insertList&feuser='.$feuser.'\';
$.post("index.php?eID=moveitems", order2,
I know how to read f.e. the value of "action2" in the php, it s easy done with "$_POST['action2'];". but how to read out the value of "$(ui.item).attr(\'id\')"? any hints are apreciated...
Pass your values as an object, it is more readable and easier to debug than a long string concatenation, e.g.:
var data = { itemid: $(ui.item).attr('id'), action2: 'insertList', feuser: $feuser };
$.post('some/where', data, function(data) {
alert(data);
});
Now the value of $(ui.item).attr('id')
will be available on the server as $_POST['itemid']
in this case, it looks like youre showing us what the code looks like on the server side, before it is sent to the user as HTML. Once on the users end, it'll look something like this:
var order2 = $(ui.item).attr('id') + '&action2=insertList&feuser=BAR'
Now $(ui.item).attr('id')
is a javascript variable. You need to find out what that value is. Once you know what that value is, you can see what it will be as part of the url. For example,
now order2
might be:
'FOO&action2=insertList&feuser=BAR'
In this case, you could check to see if $_POST['FOO'] is set. If you don't know how to evaluate javascript variable, you could always just do print_r($_POST) on the server side and see what values are passed back so you know what to expect. But if you don't know how to determine the values of javascript variables, you should definitely learn that first. Firebug, a firefox plugin can help you decode javascript values with the console.log command.
精彩评论