location.search从服务器端返回空白

时间:2017-03-23 09:31:31

标签: javascript jquery ajax

我有一个ajax调用客户端(下面列出的代码),它添加了一些数据参数,然后将该url发送到服务器以获取js文件中的一些代码。我只是想通过添加js文件中的警报来返回返回的window.location.search但是警报是空的,我的意思是,返回的查询字符串是空白的,与console.log(window.location.search)相同。我可以让window.location工作,返回http://localhost:3000/但是添加获取查询字符串值的search部分会从服务器返回空。

ajax call

var variable1 = 'currentuser1var';
$.ajax({
      type: 'GET',
      url: '/users/index',
      data: {currentuser1var: variable1},
      dataType: 'script',
    });

服务器响应

Started GET "/users/index?currentuser1var=currentuser1var&_=1490258560962" for ::1 at 2017-03-23 19:42:42 +1100
Processing by UsersController#index as JS
  Parameters: {"currentuser1var"=>"currentuser1var", "_"=>"1490258560962"}
  Rendering users/index.js.erb
  Rendered users/index.js.erb (0.0ms)
Completed 200 OK in 312ms (Views: 172.1ms | ActiveRecord: 0.0ms)

我只是想知道是否有人可能知道这是为什么,如果有当前的问题,或者我正在尝试做什么的问题,或者你可能知道这样做的事情?

0 个答案:

没有答案
相关问题