Search code examples
ruby-on-railsajax-on-rails

How to create a ajax callback function in rails


I'm new to Rails and ajaxification on Rails: I'm facing a problem in writing an ajax callback function. For example, if i am writing a callback function for a delete method and write a callback code for ajax in applicaton.js, it works fine when i have written format.js to this method as

format.js { render :nothing => true }

But what i want is both: this format.js works and also the callback function should work. How to do this?


Solution

  • Can you simply try

    format.js { render :json => {} }

    instead of

    format.js { render :nothing => true }

    so that your callback function will be called.