I'm trying to add a variable (integer) in URL to be used in an Ajax request:
In my HTML, I have:
<span class="user">15</span>
And the script:
$('#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);
}
});
});
}
});
});
However, the variable (15) isn't being passed to the URL, I get the error:
/files/NaN/data.json
I know I'm doing something stupid, and searched everywhere, but what is it?
.userelements on the page?