Desidero visualizzare alcuni prodotti Amazon, caricati tramite Ajax.Rails: richieste HTTP non bloccanti?
Io chiamo il metodo di seguito con Ajax, ma la richiesta richiede un paio di secondi.
@items = []
@shows.shuffle.first(5).each do |show|
req = AmazonProduct["us"]
req.configure do |c|
c.key = "###"
c.secret = "###"
c.tag = "###"
end
req << { :operation => 'ItemSearch',
:search_index => params[:product_type],
:response_group => %w{ItemAttributes Images},
:keywords => show.name,
:sort => "" }
resp = req.get
@items << resp.find('Item').shuffle.first
end
Non ho notato che questa azione blocca il server. Ho provato ad aprire il sito in un'altra scheda. Quella scheda non inizierà il caricamento fino al completamento della prima scheda con la chiamata Ajax.
Come posso risolvere questo problema?
Setup:
Ubuntu 10.10
Rails 3.1.1
Rubino 1.9.2
Gem: https://github.com/hakanensari/amazon_product
Oh, questo è un po 'deludente :( – Frexuz