Corrected some javascript
This commit is contained in:
parent
b48d8da271
commit
1854bac048
@ -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);
|
||||
|
Reference in New Issue
Block a user