This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
programmieren:javascript:alpinejs_ajax_beispiel [2022/09/14 08:06] – jgehrke | programmieren:javascript:alpinejs_ajax_beispiel [2022/12/17 12:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 48: | Line 48: | ||
xhttp.setRequestHeader(" | xhttp.setRequestHeader(" | ||
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( " | ||
- | console.log( response_json ); | ||
- | |||
/* | /* | ||
| | ||
Line 58: | Line 57: | ||
So we be bound the current alpine.js object to a global window variable | So we be bound the current alpine.js object to a global window variable | ||
*/ | */ | ||
- | window.this_alpinejs_module.repsonse_json = response_json; | + | window.this_alpinejs_module.repsonse_json = response_json; |
return true; | return true; |