jQuery Ajax를 통해 양식의 본문에 오류 메시지가 표시되는 팝업 로그인 양식이 있습니다. 내 로컬 환경 (PostGresQL, WEBbrick)에서는 제대로 작동하지만 Heroku에서는 작동하지 않습니다. Heroku에서 사용자는 오류 메시지 즉, { "error": "잘못된 이메일 주소 : [email protected]"}을 표시하는 새 페이지로 리디렉션됩니다.AJax + Roku가 Heroku에서 작동하지 않습니다.
페이지에는 실제로 두 개의 가입 양식이 있습니다. 하나는 jQuery Dialog를 통해 팝업되고, 다른 하나는 페이지에 임베드됩니다. 어떤 도움을 주셔서 감사합니다. 여기
컨트롤러입니다 : 클래스 MailingListController <와 ApplicationControllerrespond_to :json
def create
gb = Gibbon.new(Settings.mailchimp.api_key)
res = gb.list_subscribe({:id => Settings.mailchimp.list_id, :email_address => params[:email]})
if res == true
render(:json => {:body => "okay"})
else
render(:json => {:error => res["error"]})
end
rescue
render(:json => {:error => "Fatal Error"})
end
end
가 여기에 JS있어 (내가 코드를 복제, 알고, 난 그냥 일을 얻으려고) :
// Mailing List Watcher
var mailingList2 = $("#mailing-list2");
if (mailingList2.length) {
mailingList2
.live("completed", function(e){
})
.live("success", function(e){
var that = this;
$.cookie("mailingListSubmitted", "true", {expires: 7});
if(mailingList2.find("#mailing-list2 #status2").length == 0){
mailingList2
.find("form input[type='text']")
.after($("<div></div>").attr({id : "status2"}))
}
mailingList2
.find("form input[type='text']")
.attr("disabled", true)
.fadeOut(5000);
$("#mailing-list2 #status2")
.text("Email submitted successfully!")
.effect("highlight", { }, 1000);
})
.live("failure", function(e, error){
if(mailingList2.find("#mailing-list2 #status2").length == 0){
mailingList2
.find("form input[type='text']")
.after($("<div></div>").attr({id : "status2"}))
}
$("#mailing-list2 #status2")
.text(error)
.effect("highlight", {}, 1000);
})
.live("submittal", function(e, emailAddress){
if (emailAddress == "" || emailAddress == null) {
$(this).trigger("failure", ["You need to specify an email address!"])
return false;
}
var token = $.token();
$.post("/mailing_list", {email: emailAddress, authenticity_token: token}, function(response, status, xhr){
if(response.error){
$(mailingList2).trigger("failure", ["An error occurred: " + response.error]);
} else {
$(mailingList2).trigger("success");
}
}, "json")
.error(function(){
$(mailingList2).trigger("failure", ["An error occurred. Please try again in a few minutes."]);
});
});
mailingList2.find("form").submit(function(){
emailAddress = mailingList2.find("input[name='email']").val();
$(mailingList2).trigger("submittal", [emailAddress]);
return false;
});
var mlSetting = $.cookie("mailingListSubmitted");
if (mlSetting == "true") {
mailingList2.remove();
}
}
// Mailing List Watcher
var mailingList = $("#mailing-list");
if (mailingList.length) {
mailingList
.live("completed", function(e){
})
.live("success", function(e){
var that = this;
$.cookie("mailingListSubmitted", "true", {expires: 7});
if(mailingList.find("#status").length == 0){
mailingList
.find("form input[type='text']")
.after($("<div></div>").attr({id : "status"}))
}
mailingList
.find("form input[type='text']")
.attr("disabled", true)
.fadeOut(5000);
$("#status")
.text("Email submitted successfully!")
.effect("highlight", { }, 1000);
})
.live("failure", function(e, error){
if(mailingList.find("#status").length == 0){
mailingList
.find("form input[type='text']")
.after($("<div></div>").attr({id : "status"}))
}
$("#status")
.text(error)
.effect("highlight", {}, 1000);
})
.live("submittal", function(e, emailAddress){
if (emailAddress == "" || emailAddress == null) {
$(this).trigger("failure", ["You need to specify an email address!"])
return false;
}
var token = $.token();
$.post("/mailing_list", {email: emailAddress, authenticity_token: token}, function(response, status, xhr){
if(response.error){
$(mailingList).trigger("failure", ["An error occurred: " + response.error]);
} else {
$(mailingList).trigger("success");
}
}, "json")
.error(function(){
$(mailingList).trigger("failure", ["An error occurred. Please try again in a few minutes."]);
});
});
mailingList.find("form").submit(function(){
emailAddress = mailingList.find("input[name='email']").val();
$(mailingList).trigger("submittal", [emailAddress]);
return false;
});
var mlSetting = $.cookie("mailingListSubmitted");
if (mlSetting == "true") {
mailingList.remove();
}
}
가 오류의 스택 추적을 게시 할 수 있습니까를? 오류는 자바 스크립트 코드가 아니라 환경 설정과 관련이 있습니다. – BlueFish