應用 - 2(Java和Rails)的Rails request.xhr?不工作
導軌 - 3.0.3
紅寶石 - 1.8.7
客戶 - 使用jQuery從Java應用程序
Firebug的Ajax調用 - 顯示它實際上是一個Ajax XHR請求(XHR選項卡)
Server - Rails - request.xhr? 假
任何寶石丟失爲Ajax響應(只從Java PP AJAX請求)
我的寶石列表如下:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (3.0.3)
activemodel (3.0.3)
activerecord (3.0.3)
activeresource (3.0.3)
activesupport (3.0.3)
arel (2.0.4)
builder (2.1.2)
bundler (1.3.4)
cgi_multipart_eof_fix (2.5.0)
columnize (0.3.6)
crack (0.1.8)
daemons (1.1.0)
delayed_job (2.1.2)
erubis (2.6.6)
fastthread (1.0.1)
gem_plugin (0.2.3)
hoptoad_notifier (2.3.12)
httparty (0.6.1)
i18n (0.4.2)
linecache (0.46)
mail (2.2.10)
mime-types (1.16)
mongrel (1.1.5)
mysql2 (0.2.6)
nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.6)
rails (3.0.3)
railties (3.0.3)
rake (0.8.7)
rbx-require-relative (0.0.9)
ruby-debug (0.10.4)
ruby-debug-base (0.10.4)
ruby-xslt (0.9.7)
rubygems-bundler (1.1.1)
rubyzip (0.9.4)
rvm (1.11.3.6)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.23)
xml-simple (1.0.12)
我的控制器代碼是
def index
if request.xhr?
logger.debug " Ajax request yes"
else
logger.debug " Ajax request false"
end
respond_to do |format|
format.html
format.js
end
end
jquery的代碼是:
$.ajax({
type: "GET",
url:"someurl"
cache:false,
success: function(data) {
alert('success');
},
error: function(jqXHR, textStatus, errorThrown){
alert(jqXHR.responseText);
}
服務器日誌
Started GET "/mozart_content?id=phyp10084_sa102&dt=20130704132018&api=a3aee3fa-567e-11df-be64-7779fa786bb0&sign=WBCbzBY0GDAP6mQVLxcFZX-ES10%3D" for 192.168.42.27 at Thu Jul 04 18:49:44 +0530 2013
Processing by MozartContentController#index as HTML
Parameters: {"sign"=>"WBCbzBY0GDAP6mQVLxcFZX-ES10=", "api"=>"a3aee3fa-567e-11df-be64-7779fa786bb0", "dt"=>"20130704132018", "id"=>"phyp10084_sa102"}
Ajax request false
Rendered mozart_content/index.html.erb within layouts/application (149.3ms)
Completed 200 OK in 155ms (Views: 154.3ms | ActiveRecord: 0.0ms)
請發佈您的控制器代碼 – bluehallu
添加控制器代碼 – rails007
您可以發佈服務器日誌中的一個請求嗎? – bluehallu