I use the following method to generate a board of threads, whether it’s a specific page, or the whole catalog.
function displayThreads() {
function addBoardThread(threadArr, threadNum) {
$.ajax({
url : 'to/url/make.php',
method : 'POST',
data : {
threads : threadArr,
thread_no : threadNum,
return : url.pathname
}
}).done(function(html) {
$('#board').html($('#board').html() + html);
}).fail(function(msg) {
console.log(msg);
});
}
let url = new URL(window.location.href);
let page = url.searchParams.get('page');
let threadArr = [];
$.ajax({
url : 'thread_order.csv',
method : 'GET'
}).done(function(data) {
threadArr = data.split(',');
}).fail(function(msg) {
console.log(msg);
}).then(function() {
$('#board').html('');
let threadNo = 0;
if (fullToggle) {
for (let i = 0; i < threadArr.length; i++) {
addBoardThread(threadArr, i);
}
} else {
for (let i = 10 * (page-1); i < 10 * page; i++) {
addBoardThread(threadArr, i);
}
}
});
}
My current issue is that when I try loading all the board’s thread into one page (when fullToggle is true), I get a 500 server message, but in the alternate case, I get a 200 server message.
This issue is from the ajax request in the “addBoardThread” function.
This is the object that gets returned from the ajax request when I receive the 500 server message
Object { readyState: 4, getResponseHeader: getResponseHeader(e), getAllResponseHeaders: getAllResponseHeaders(), setRequestHeader: setRequestHeader(e, t), overrideMimeType: overrideMimeType(e), statusCode: statusCode(e), abort: abort(e), state: state(), always: always(), catch: catch(e), … }
abort: function abort(e)
always: function always()
catch: function catch(e)
done: function add()
fail: function add()
getAllResponseHeaders: function getAllResponseHeaders()
getResponseHeader: function getResponseHeader(e)
overrideMimeType: function overrideMimeType(e)
pipe: function pipe()
progress: function add()
promise: function promise(e)
readyState: 4
responseText: "<hr/><div class=thread-details>nt<span class=thread-details data-tooltip=Replies>4</span>nt/nt<span class=thread-details data-tooltip=Files>2</span>nt/nt<span class=thread-details data-tooltip=Page>1</span>n</div><hr/><div class=board-thread id=board-thread-13>"
setRequestHeader: function setRequestHeader(e, t)
state: function state()
status: 500
statusCode: function statusCode(e)
statusText: "Internal Server Error"
then: function then(t, n, r)
I receive this error for every thread that is in the board when I send the ajax request only when trying to get all threads.
I just try to send a post request with the most up-to-date thread array, the index of what thread I want to extract and the return address, so I know where to draw from.
This code works perfectly well when selecting only a page of threads, but requesting all breaks the code
Dylan Colton is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1