# Rails 3.2 jQuery JSONP request not working - Moved Permanently

**URL:** <https://www.ruby-forum.com/t/rails-3-2-jquery-jsonp-request-not-working-moved-permanently/225587>\
**Category:** Rails\
**Created:** [January 16, 2013, 11:42pm UTC](https://www.ruby-forum.com/t/rails-3-2-jquery-jsonp-request-not-working-moved-permanently/225587 "2013-01-16T23:42:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [January 16, 2013, 11:42pm UTC](https://www.ruby-forum.com/t/rails-3-2-jquery-jsonp-request-not-working-moved-permanently/225587/1 "2013-01-16T23:42:52Z")

</div>

I am trying to send a POST request ( ‘remove\_tag\_named’ )and getting a  
simple OK back on success ; it doesn’t work…  
the post is correctly sent , but after then it’s looping on sending a  
GET  
request to the same url, with the error  
301 Moved Permanently

I should not be far fro the solution, but I am stuck :

In my routes.rb  
_namespace :administration_ do  
_resource :dashboards_, :only =\> :show do  
collection do  
_post :remove\_tag\_named_  
end  
end  
end

In my view :  
_= link\_to t(:delete), “#”, :id =\> :delete\_tag\_link_  
# generated html =\>

- remove

my js.coffee script ( # this should be using JSONP I guess )  
$(‘_#delete\_tag\_link_’).bind “click”, (e) →   
selected = $(‘#tags.tab-pane.active #tag-list li  
span.myTag.selected’)  
tagName = selected.html()  
alert 'going remove tag: ’ + tagName # checking I get the correct  
tag  
value  
$.ajax  
url: “/” + locale +  
“/administration/dashboards/remove\_tag\_named.json”  
type: “POST”  
dataType: “json”  
contentType: “json”  
data: {“tag\_name”: tagName }  
success: (result) →   
selected.remove()

I have also set an init js

$.ajaxSetup beforeSend: (xhr) →   
xhr.setRequestHeader “X-CSRF-Token”,  
$(“meta[name="csrf-token"]”).attr(“content”)

and the console output :  
[23:18:24.424] POST  
[http://localhost:3000/fr/administration/dashboards/remove\_tag\_named.json](http://localhost:3000/fr/administration/dashboards/remove_tag_named.json)  
[HTTP/1.1 301 Moved Permanently 46ms]  
[23:18:24.491] GET  
[http://localhost:3000/fr/administration%2Fdashboards%2Fremove\_tag\_named.json](http://localhost:3000/fr/administration%2Fdashboards%2Fremove_tag_named.json)  
[HTTP/1.1 301 Moved Permanently 34ms]  
[23:18:24.547] GET  
[http://localhost:3000/fr/administration%2Fdashboards%2Fremove\_tag\_named.json](http://localhost:3000/fr/administration%2Fdashboards%2Fremove_tag_named.json)  
[HTTP/1.1 301 Moved Permanently 35ms]  
[23:18:24.550] GET  
[http://localhost:3000/fr/administration%2Fdashboards%2Fremove\_tag\_named.json](http://localhost:3000/fr/administration%2Fdashboards%2Fremove_tag_named.json)  
[HTTP/1.1 301 Moved Permanently 48ms]  
… more GET…
