는 Ajax 요청에 사용되는 아약스의 URL에 변수를 전달합니다내가 URL에서 변수 (정수)를 추가하기 위해 노력하고있어
<span class="user">15</span>
그리고 내 HTML에서
을, 내가 가진 스크립트
/files/NaN/data.json
:
$('#fileupload').click(function() {
$(this).fileupload({
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
if (file.error != null) {
$console.text(file.error);
}
var user = parseInt($(".user").text(), 10);
//Open the uploaded file//
$.ajax({
url: "files/" + user + '/' + file.name,
dataType: 'json',
type: 'GET',
success: function (res) {
handsontable.loadData(res.data);
$console.text('Loaded file: ' + file.name);
}
});
});
}
});
});
그러나 변수 (15)가 URL에 전달되지 않는, 나는 오류
나는 바보 같은 짓을하고 도처에서 수색했음을 알고 있지만 무엇입니까?
페이지에 여러 개의'.user' 엘리먼트가 있습니까? – Barmar
그게 문제라고 생각합니다. 그 이름을 다른 것으로 바꿨습니다. 감사! –