0
例如,我目前在/用戶頁面,當我從該頁面發送請求是指/用戶/會話/ ID,而我只需要交談/ ID。如何做?如何繞過Ajax中GET請求方法的當前頁面?
users.js
$('.start-conversation').click(function (e) {
e.preventDefault();
var sender_id = $(this).data('sid');
var recipient_id = $(this).data('rip');
$.post("/conversations", { sender_id: sender_id, recipient_id: recipient_id }, function (data) {
chatBox.chatWith(data.conversation_id);
});
});
chat.js
$.get("conversations/" + conversation_id, function (data) {
$('#chatbox_' + conversation_id).html(data);
$("#chatbox_" + conversation_id + " .chatboxcontent").scrollTop($("#chatbox_" + conversation_id + " .chatboxcontent")[0].scrollHeight);
}, "html");
前面你想要的絕對路徑。 – SLaks
@PatrickEvans創建一個答案,我可以接受它 –
@PatrickEvans你幫了我,謝謝 –