且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在服务器端脚本中的ajax调用中访问jquery数据变量

更新时间:2023-11-21 11:52:46

Aj就在这里,因为我没有列出我正在使用的服务器端代码,所以我想使用php,但简单地说,我将ajax调用更改为>

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'},
});

其中键是currentuser1var,值variable1是字符串,并且省略了定义变量的位置,否则位于代码中.这样,URL可以正确地到达/users/show?currentuser1var=variable1服务器.然后在我的目标文件中添加我的ruby代码以使用这些变量.

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.