Skip to content
Advertisement

Jquery/ Ajax: Send additional php variable to server sided script

I have this select box. The selected option is sent with ajax to a server side script.

JavaScript

jquery script

JavaScript

And in the server sided script (itemscript.php) I get the variable from the select box like that:

JavaScript

Now I want to extend this script to send an additional php variable called $element to the server sided script (itemscript.php). The $element variable is a part of the the current url address.

How can I send the additional $element variable within this jquery/ ajax script?

Advertisement

Answer

Just add the other data items into the data{} part, separated by commas.

Assuming that your $element data is inside an inputbox, then

HTML

JavaScript
JavaScript

In the above, $_POST[“element”] will be passed to your php scripts

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement