검색되지 않은 예외: Ajax Process의 메모리 부족
나는 작은 데이터가 있는 간단한 양식을 제출하고 있고 체크인 할 때 문제가 생겼습니다.console
탭 ajax의 URL이 작동하는 것처럼 보이지만 ajax가 처리된 후 오류가 발생하여 내 홈페이지와 콘솔 탭으로 리디렉션됩니다.weird error
:
검색되지 않은 예외: 메모리 부족
나의 아약스에서는 다음과 같은 간단한 코드만 있습니다.
$("#add-comment").on('click', function() {
var id = $('input[name=\'review_id\']').val();
var customer_id = $('input[name=\'customer_id\']').val();
var $comment = $('textarea[name=\'user_comment\']').val();
var sample = "test";
$.ajax({
url: 'index.php?route=product/product/writeSubComment',
type: 'post',
dataType: 'json',
data: { text: sample },
beforeSend: function() {
},
success: function(data) {
console.log(data.test);
},
error: function() {
alert('ERROR!!!');
}
});
});
내 PHP 컨트롤러에 이 기능이 있습니다.
public function writeSubComment() {
$json = array();
$json['test'] = $this->request->post['text'];
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
홈페이지로 리다이렉트 된 것에 대한 당신의 설명으로 볼 때, 당신의 ax 응답 섹션에 이를 위한 코드가 없는 것으로 보아 #add-comment 요소가 당신의 양식에 있는 제출 버튼이 아닌가 의심됩니다.
이 경우 #add-comment submit 버튼을 클릭하면 axis 코드가 실행되는 동시에 양식이 제출될 수 있습니다.그러면 페이지가 리디렉션되는 동안 ajax javascript가 삭제되므로 메모리 부족 오류가 발생합니다.
양식이 제출되지 않도록 하고 성공() 또는 실패 섹션에서 다음 단계(예: 페이지 새로 고침, 주석 상자 업데이트)를 처리하도록 해야 합니다.이것을 하는 한가지 방법은 변화하는 것일 것입니다.
$("#add-comment").on('click', function() {
...
로.
$('#add-comment').on('click', function(event){
event.preventDefault();
...
또는 제출 단추를 에서 변경합니다.
<button type="submit" ...>Add comment</button>
로.
<button type="button" ...>Add comment</button>
아니면 이렇게 양식 태그를 변경합니다.
<form onsubmit="return false;">
이것이 제가 가지고 있는 정보에서 가장 잘 짐작할 수 있는 것입니다.
파이어폭스에서 테스트하는 동안 비슷한 문제가 있었습니다.단추 변경type
부터submit
로.button
나를 위해 일했습니다.
<button type="submit" ...>Add comment</button>
로.
<button type="button" ...>Add comment</button>
결과를 HTML DOM에 표시하려고 했을 때, 저는 Ajax를 통한 검색 구현에서 이 오류가 발생했습니다.
$('..a place where the processed output Ajax request..').on('click', '#add-comment', function() {...});
나의 문제는 바꿈으로써 해결되었습니다.
<button onClick="save_order_info_into_database()">Save</button>
안으로
<button type="button" onClick="save_order_info_into_database()">Save</button>
추가하는 방법으로type="button"
내것을 해결했습니다..
언급URL : https://stackoverflow.com/questions/29291952/uncaught-exception-out-of-memory-in-ajax-process
'source' 카테고리의 다른 글
쿼리가 두 번째로 실행되면 더 빨리 실행됩니다. 이를 중지하려면 어떻게 해야 합니까? (0) | 2023.10.09 |
---|---|
자바스크립트에서 이진수를 나타내는 "0b" 등이 있습니까? (0) | 2023.10.09 |
파워셸에서 sqlcmd를 실행하는 방법? (0) | 2023.10.09 |
각도 2 - 외부 URL로 리디렉션하고 새 탭에서 엽니다. (0) | 2023.10.09 |
자바스크립트 / jQuery:윈도우에 포커스가 있는지 테스트 (0) | 2023.10.09 |