I have a ajax call client side (code listed below) which adds some data parameters then sends that url to the server to get some code in a js file. I just wanted to see what window.location.search
returned by adding in a alert in that js file to send back but the alert is empty, by that i mean, the query string returned is blank, the same as console.log(window.location.search)
. I can get window.location
to work, returns http://localhost:3000/
but adding the search
part which gets the query string value returns empty from the server.
ajax call
var variable1 = 'currentuser1var';
$.ajax({
type: 'GET',
url: '/users/index',
data: {currentuser1var: variable1},
dataType: 'script',
});
Server response
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)
I am just wondering if anyone might know why this is, if there is a current issue, or problem with what I am trying to do, or something you may know of from doing this?