html로 html 코드를 삽입하고 다른 모든 버튼이 sqlite 데이터베이스에 데이터를 보내는이 태평양 버튼을 사용하더라도 다음 오류가 발생합니다.오타가있는 코드를 삽입 할 때 구문 오류가 발생할 수 있습니까?
catch되지 않은 구문 에러 :
문제 인수 목록 뒤에)가 없습니다 나는 코드를 검토하고 다양한 접근과 시도했습니다에만 포인트 DOCTYPE에 무슨 잘못이 늘 잡을 코드를 주입 메신저 이후?
되는 HTML
주입되고 :$(info).html('<h4 class="media-heading">' + response[rCnt].title + '</h4><h3><span class="glyphicon glyphicon-star" aria-hidden="true"> </span> ' + response[rCnt].social_rank.toFixed(2) + '</h3><h3><span class="glyphicon glyphicon-print" aria-hidden="true"> </span> ' + response[rCnt].publisher + '</h3><h3><span class="glyphicon glyphicon-home" aria-hidden="true"> </span> <a> ' + response[rCnt].source_url + '</a></h3><button type="button" class="btn btn-default" id="button1" onclick="saveRecipe(' + response[rCnt].title + ',' + response[rCnt].social_rank.toFixed(2) + ',' + response[rCnt].publisher + ',' + response[rCnt].source_url + ')" title="Save"><span class="glyphicon glyphicon-save" aria-hidden="true"></span></button>');
HTML 버튼 내부의 쉽게 읽을 수 있도록 :
<button type="button" class="btn btn-default" id="button1" onclick="saveRecipe(' + response[rCnt].title + ',' + response[rCnt].social_rank.toFixed(2) + ',' + response[rCnt].publisher + ',' + response[rCnt].source_url + ')" title="Save"><span class="glyphicon glyphicon-save" aria-hidden="true"></span></button>
되는 HTML 버튼에 데이터를 제공하는 AJAX 호출 :
function saveRecipe(title, rank, auth, src) {
$.ajax({
type: "POST",
headers: {
"Content-Type": "application/json"
},
url: "/SaveFile",
data: JSON.stringify({
name: title,
rating: rank,
author: auth,
source: src
}),
success: function(response) {
console.log("Hii");
console.log(response);
},
error: function(response, error) {
console.log(response);
console.log(error);
}
});
}
버튼의 출력 HTML이 무엇입니까? 또는 실제로는 onclick 속성의 값입니다. –
나는 기능의 콘솔 로그를 ddi했고 다음을 얻었다. POST http://127.0.0.1:5000/SaveFile 500 (내부 서버 오류) –