Accessing Jquery Data Variable In Ajax Call In Server Side Script
I have a few ajax calls in my app they all go to the same file server side. i want to know if I can use a variable... I want to have a way to distinguish the call from other calls
Solution 1:
If you were using PHP, your server side script would be:
if(isset($_GET['currentuser1var'])) {
... script to process the currentuser1var variable ...
} elseif (isset($_GET['currentuser2var'])) {
... script to process the currentuser2var variable ...
}
Solution 2:
Aj was right here I guess for php as I did not list what server side code I was using, but simply put, I changed my ajax call to
return $.ajax({
type: 'GET',
url: '/users/show',
data: { currentuser1var: 'variable1'},
});
where the key is currentuser1var
and the value variable1
is a string and leave out defining the variable else where in the code. That way the url comes through correctly to the server being /users/show?currentuser1var=variable1
. And in my destination file add my ruby code there to use the variables.
Post a Comment for "Accessing Jquery Data Variable In Ajax Call In Server Side Script"