d0a98042 | 13 May 09:06
Picon
Favicon

[Rails] Masalah dengan prototype.js

Guys..tolongin..

Saya coba manggil sebuah action di view dengan kode spt ini 

<%= collection_select :address, :country_id, @countries, :id, :name,
{:include_blank => true}, {:onchange => 'showProvinces(this.value)'} -%>

saat onchange, function showProvinces (javascript) akan di panggil.
Isi function showProvinces kaya gini 

var url = '/user/find_provinces/' + country_id;
    new Ajax.Request(url, {
      method: 'post',
      onSuccess: function(transport) {
        alert(transport.responseText);
      }
    });

dan action find_provinces saya kaya gini 

def find_provinces
    @provinces =  Province.find(:all, :conditions => [ "country_id =
?", params[:id] ])
    if (request.xhr?)
      render :text => @provinces.to_json    
    end
  end

saya ingin apa yang dikembalikan oleh method find_provinces itu akan
muncul di alert yang saya panggil di view
(Continue reading)

d0a98042 | 13 May 09:28
Picon
Favicon

Re: [Rails] Masalah dengan prototype.js

Edit dikit guys..harusnya gini

var url = '/user/find_provinces/' + country_id;
    new Ajax.Request(url, {
      method: 'get',
      onSuccess: function(transport) {
        alert(transport.responseText);
      }
    });

------------------------------------

ID-Ruby
Berdiskusi dan belajar bersama Bahasa Pemrograman Ruby, termasuk segala varian Ruby (JRuby, Rubinius,
IronRuby, XRuby), dan program yang dibuat dengan Ruby (Ruby on Rails, JRuby on Rails, Merb)

<*> Kunjungi *arsip milis* id-ruby di
    http://groups.yahoo.com/group/id-ruby/messages
    http://www.mail-archive.com/id-ruby-hHKSG33TihhbjbujkaE4pw <at> public.gmane.org/
    http://rubyurl.com/Q8DD
    http://news.gmane.org/gmane.comp.lang.ruby.region.indonesia

<*> Baca peraturan id-ruby sebelum posting
    http://rubyurl.com/gay1

<*> Ikutilah Jajak Pendapat ID-Ruby
    http://rubyurl.com/3CCt

<*> Links ID-Ruby
    http://rubyurl.com/n96r
(Continue reading)

d0a98042 | 13 May 10:43
Picon
Favicon

Re: [Rails] Masalah dengan prototype.js

Guys..ternyata masalah saya ada di InvalidAuthenticityToken. Maksudnya
apa ya?

------------------------------------

ID-Ruby
Berdiskusi dan belajar bersama Bahasa Pemrograman Ruby, termasuk segala varian Ruby (JRuby, Rubinius,
IronRuby, XRuby), dan program yang dibuat dengan Ruby (Ruby on Rails, JRuby on Rails, Merb)

<*> Kunjungi *arsip milis* id-ruby di
    http://groups.yahoo.com/group/id-ruby/messages
    http://www.mail-archive.com/id-ruby-hHKSG33TihhbjbujkaE4pw <at> public.gmane.org/
    http://rubyurl.com/Q8DD
    http://news.gmane.org/gmane.comp.lang.ruby.region.indonesia

<*> Baca peraturan id-ruby sebelum posting
    http://rubyurl.com/gay1

<*> Ikutilah Jajak Pendapat ID-Ruby
    http://rubyurl.com/3CCt

<*> Links ID-Ruby
    http://rubyurl.com/n96r

<*> Database ID-Ruby
    http://rubyurl.com/Iw3u

<*> Kunjungi Situs Resmi Ruby Indonesia
    http://www.ruby-lang.org/id/

(Continue reading)


Gmane