Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
programmieren:javascript:alpinejs_ajax_beispiel [2022/09/14 08:07] jgehrkeprogrammieren:javascript:alpinejs_ajax_beispiel [2022/12/17 12:28] (current) – external edit 127.0.0.1
Line 48: Line 48:
  xhttp.setRequestHeader("Content-Type", "application/json");  xhttp.setRequestHeader("Content-Type", "application/json");
  xhttp.onreadystatechange = function() {  xhttp.onreadystatechange = function() {
- if(this.readyState == 4 && this.status == 200) {+ const is_call_success = (this.readyState == 4 && this.status == 200) ? true : false; 
 +  
 + if( is_call_success ) {
  const response_json = JSON.parse( this.response );  const response_json = JSON.parse( this.response );
- console.log( "Antwort: " ); 
- console.log( response_json ); 
- 
  /*  /*
       in current context 'this' would refer to the XMLHttpRequest Object       in current context 'this' would refer to the XMLHttpRequest Object

Page Tools