I'm building an Rails app and I'm trying to do an AJAX call with jQuery. When I do the AJAX call (POST), I receive an error from my method. But I don't know what the problem is :(
Everything worked when I'm using the 'GET' method, but when I change it to 'POST', I'm receiving the error (and yes, I changed the route.rb :) )
jQuery
$.ajax({
url: "/login/checkLogin/",
dataType: "json",
data: data,
type: 'post',
}).done(function(response){
console.log(response);
})
Method
ldap = Net::LDAP.new
ldap.host = "***"
ldap.port = ***
ldap.auth %[#{params[:login_username]}], params[:login_password]
if ldap.bind
session['loggedin'] = true
respond_with "1".to_json
else
session['loggedin'] = false
respond_with "0".to_json
end
The error message (coming from the console)
undefined method `"0"_url'
Thanks