这是我的rails html.erb页面
<a data-remote="true" data-type="json" href="/project/4/request_access">Request Access</a>
这是我在同一页面上的javascript
$(document).ready(function() {
$("body").on("ajax:complete", function(e) {
console.log("Got Ajax complete: ");
console.log(e);
});
}
我的终端获得了200的成功。我在我正在寻找的响应中获取数据,但是从不调用控制台日志。我之前对于身份更加具体,但是去了身体&#39;只是抓住一切。它仍然无法正常工作。怎么了?
网络响应:
General
Request Method:GET
Status Code:200 OK
Request Headers
Accept:application/json, text/javascript, */*; q=0.01
X-Requested-With:XMLHttpRequest
Response
{"success":"You have been added to Y-find"}
答案 0 :(得分:0)
你可以这样试试:
<a id="remote" data-remote="true" data-type="json" href="/project/4/request_access">Request Access</a>
$(document).ready(function() {
$("#remote").on("ajax:success", function (e, data, status, xhr) {
console.log( xhr.responseText )
});
$("#remote").on("ajax:error", function(e, xhr, status, error) {
console.log ("ERROR");
});
});