我在這裏遇到了一些問題。 我試圖實現以jQuery/ajax生成模式/窗體並在該模式內應該是另一個Ajax調用(使用2個特定的ID生成)。調用jquery.ajax內部生成的ajax
希望這一點更加明確:
我得到了我的網頁,點擊「生成表單」。 然後jquery通過ajax加載模態& get url:「/ modal/id1/id2」(整個表單被加載)。 這仍然有效。 現在我想在這種形式的按鈕「張貼表單」,張貼此表單到相同的網址「/模式/ ID1/ID2」 並覆蓋當前模式與「內部」AJAX調用的結果。
我得到這個錯誤:
POST http://localhost/modal/id1/id2 500 (Internal Server Error) jquery.min.js:6
send jquery.min.js:6
x.extend.ajax jquery.min.js:6
(anonymous function) VM7593:4
x.event.dispatch jquery.min.js:5
它看起來像阿賈克斯只是不工作。 以下是我使用的一點點代碼: 此代碼生成第一個模態。不過做工精細:
<script>
$('[data-toggle="view"]').on('click',function(e) {
e.preventDefault();
var id1 = $(this).data('id1');
var id2 = "<?php echo $id2; ?>"
$.ajax({
type: "GET",
url: "offers/"+id1+"/create/"+id2,
dataType: "html",
success: function(response){
$('#offerModal').html(response);
$('#offerModal').modal('toggle');
}
});
});
</script>
這是第一AJAX請求返回,並在模態顯示的代碼:
<script>
$('#createOffer').on('click',function(){
$.ajax({
type: "post",
url: "offers/1/create/2", //url exists and is working
data: { test: "test" },
success: function(response){
alert(response);
}
});
});
</script>
希望您能(瞭解我的問題和)幫我一下吧。
謝謝!
你確定httaccess可能與ajax? – 2014-10-27 20:35:51
是的,因爲第一個Ajax調用正在工作。我打了2次相同的網址。一次獲得和一次後 – conehead 2014-10-27 20:38:03
爲什麼你不試圖把第二次ajax電話放在第一個電話所在的地方。只是爲了看看它是如何工作的。 – 2014-10-27 20:47:38