1

The following is the part 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...

1
  • i dont know how to fix the formatting. Commented Feb 2, 2010 at 9:00

2 Answers 2

2

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']

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.