Problem with jquery ajax call and js.rjs code

On one of my pages, i make a remote request to the update action of my
school_subscribers controller with a jquery ajax call.

In my log, i can see that the action executes fine, and the
corresponding js.rjs file is evaluated (i’m logging from inside that
file and it all seems fine). I can see in the firebug console that i
get a 200 back from the remote request. But, the code in the js.rjs
file isn’t actually executed. I tried the simplest possible case of
having it just do

page.alert(“hello”)

but no joy.

I think that this is just a problem with how i have my jquery ajax
options set up - possibly the datatype option. I tried omitting
datatype, and setting it to ‘script’, or ‘html’ but neither worked.

here’s my call:

function updateSubscriber(id, paramString){
  jQuery.ajax({
    async:true,
    type: "PUT",
    datatype: 'script',
    url: "/music_service/"+<%= @music_service.id

%>+"/school_subscribers/"+id,
data: (paramString),
error: function(msg){
alert(“Sorry, there was an error updating this subscriber”);
}
});
}

Can anyone see what i’m doing wrong? Should i be using an ajax call in
this case?

Even more maddening - i decided to try to do it with a button_to_remote
instead:

<%= button_to_remote “Mark as not paid”, :url =>
music_service_school_subscriber_path(@music_service, subscriber,
:school_subscriber => {:paid => 0}), :method => :put, :failure =>
“alert(‘Sorry there was an error updating this subscriber’)” %>

This generated the following, on the page (i added whitespace to make it
more readable), which works, and appears to be exactly the same as i had
when i hand-wrote the js! wtf? how come the code below works and the
code above doesn’t?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs