7acb2ca533
Renamed "includes" to "templates" Added .htaccess to redirect requests to index.php Added function to split request URL into array Corrected locations in scripts and pages
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
function urlinsert() {
|
|
var url = document.getElementById ( "form-url" ).value;
|
|
var xhr = new XMLHttpRequest ( );
|
|
xhr.open ( "POST", 'insert', true );
|
|
xhr.onreadystatechange = function ( ) {
|
|
if ( xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200 ) {
|
|
if (xhr.status == 200) {
|
|
var response = xhr.responseText;
|
|
response = JSON.parse ( response );
|
|
if ( response [ 'status' ] == 200 ) {
|
|
document.getElementById ( "responsetext" ).innerHTML = response [ 'message' ];
|
|
var div = document.createElement ( 'div' );
|
|
div.innerHTML = response [ 'new_id' ] + " | " + url;
|
|
document.getElementById ( "urllist" ).appendChild ( div );
|
|
document.getElementById ( "form-url" ).value = "";
|
|
}
|
|
else {
|
|
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
|
|
}
|
|
}
|
|
else {
|
|
console.log ( 'Server communication error: ' + xhr.statusText );
|
|
}
|
|
}
|
|
}
|
|
data = new FormData ( );
|
|
data.append('url', url);
|
|
xhr.send( data );
|
|
}
|
|
function logout ( ) {
|
|
window.location.href = script_name+"/logout";
|
|
}
|