0
0

Corrected some javascript

This commit is contained in:
Bryan 2019-06-02 09:27:47 +02:00
parent b48d8da271
commit 1854bac048
No known key found for this signature in database
GPG Key ID: 6CB4C49B61AD50EF

View File

@ -3,12 +3,15 @@ function urlinsert() {
var xhr = new XMLHttpRequest ( );
xhr.open ( "POST", 'insert', true );
xhr.onreadystatechange = function ( ) {
if ( xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200 ) {
if (xhr.status == 200) {
if ( xhr.status == 200 ) {
if ( xhr.readyState == XMLHttpRequest.DONE ) {
var response = xhr.responseText;
response = JSON.parse ( response );
if ( response [ 'status' ] == 200 ) {
document.getElementById ( "responsetext" ).innerHTML = response [ 'message' ];
setTimeout( function( ) {
document.getElementById ( 'responsetext' ).innerHTML = ""
}, 1500 );
var div = document.createElement ( 'div' );
div.innerHTML = response [ 'last_insert' ] + " | " + url;
document.getElementById ( "urllist" ).appendChild ( div );
@ -16,12 +19,21 @@ function urlinsert() {
}
else {
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
setTimeout( function( ) {
document.getElementById ( 'responsetext' ).innerHTML = ""
}, 1500 );
}
}
else {
console.log ( 'Server communication error: ' + xhr.statusText );
}
}
else {
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
setTimeout( function( ) {
document.getElementById ( 'responsetext' ).innerHTML = ""
}, 1500 );
}
}
data = new FormData ( );
data.append('url', url);