아래 코드에서 두 매개 변수를 Ajax 호출에 전달하려고합니다. 그러나 페이지를로드 할 때 아래에 표시된 JavaScript 오류가 발생합니다. 이 오류는 버튼 클릭으로 아약스를 트리거하려고하기 전에 발생합니다 (아래 표시된 코드는 작동 버튼 클릭 이벤트 핸들러 코드에 있음). 여러 변수를 전달하는 Jquery .post()가 작동하지 않습니다.
내가 코드의 .post() 블록을 주석
, 어떤 자바 스크립트 오류없이 잘 페이지가로드. 다음은 코드입니다. 이 게시물을 참조하는 방법을 수행 한 후 ajax .post()에 2 개의 매개 변수를 전달하는 것은 이번이 처음입니다. Sending Multiple variables with Jquery ajax누구든지 내 코드에 무슨 문제가 있다고 말할 수 있습니까? 내 경고 문은 모두 올바르게 작동하고 올바른 데이터를 표시합니다. Cakephp를 사용하고 있으므로 약간의 cakephp 문법이 있습니다.
//Get the merchant config
alert("you got here!");
bookingdate = $(this).parent().parent().find("#bookingdate").serialize();
merchant_id = $(this).parent().parent().find("#merchant_id").serialize();
alert (bookingdate + " " + merchant_id);
$.post("<?php echo Router::url(array('controller'=>'MCP','action'=>'getMtRestaurant')); ?>", {bookingdate, merchant_id}, function() {
})
.done(function(data) {
alert(data.response);
//parseddata = JSON.parse(data);
$('.ajax_booking_edit').append(data);
})
.fail(function() {
alert("There was a problem retrieving the booking!");
})
.always(function() {
//alert("finished (always)");
});
나는 serialize 된 후 bookingdate 및 merchant_id를 표시하는 알림 팝업 아래에 표시됩니다.
당신은 JQuery와, 즉'잘못된
안녕하세요 .. 제가 Cakephp 코드를 언급 했으므로 .post() 호출에서 올바른 URL을 출력합니다. – aDvo