Letraindusoir Posted May 23, 2021 Posted May 23, 2021 (edited) Reference website: https://www.quanzhanketang.com/ajax/tryajax_header.html?filename=tryajax_header Reference Code: <!DOCTYPE html> <html> <body> <p>The getAllResponseHeaders() function returns the header information of a resource, like length, server-type, content-type, last-modified, etc.</p> <button onclick="loadDoc()">Get header information</button> <p id="demo"></p> <script> function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { document.getElementById("demo").innerHTML = xhttp.getAllResponseHeaders(); } }; xhttp.open("GET", "ajax_info.txt", true); xhttp.send(); } </script> </body> </html> I modify it as follows: <!DOCTYPE html> <html> <body> <p>The getAllResponseHeaders() function returns the header information of a resource, like length, server-type, content-type, last-modified, etc.</p> <button onclick="loadDoc()">Get header information</button> <p id="demo"></p> <script> var arh=""; function requery() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { arh = xhttp.getAllResponseHeaders(); } }; xhttp.open("GET", "ajax_info.txt", true); xhttp.send(); } function loadDoc(){ requery(); document.getElementById("demo").innerHTML = arh;} </script> </body> </html> Results can be obtained, but need click twice, not sure why..... Modify it once again as follows: <!DOCTYPE html> <html> <body> <p>The getAllResponseHeaders() function returns the header information of a resource, like length, server-type, content-type, last-modified, etc.</p> <button onclick="loadDoc()">Get header information</button> <p id="demo"></p> <script> arh=""; function requery(header) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function(header) { if (xhttp.readyState == 4 && xhttp.status == 200) { header=xhttp.getAllResponseHeaders(); } }; xhttp.open("GET", "ajax_info.txt", true); xhttp.send(); } function loadDoc(){ requery(arh); document.getElementById("demo").innerHTML = arh;} </script> </body> </html> but no result. if Au3, function requery(byRef header) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function(header) { if (xhttp.readyState == 4 && xhttp.status == 200) { header=xhttp.getAllResponseHeaders(); } }; xhttp.open("GET", "ajax_info.txt", true); xhttp.send(); } it can use the function 'requery' to change the value of the-address-parameter 'header', but do not know how with js Please share experiences with me, more thanks in advance! Edited May 23, 2021 by Letraindusoir
bogQ Posted May 26, 2021 Posted May 26, 2021 (edited) You can change global variable data or object and set new data or even better make a return if that is available. Note that your question is on wrong place, this is autoit help and support part of forum, not a javascript support . https://stackoverflow.com/a/7744623/1775164 Note that your calling innerHTML = arh; probably before data is fetched, so delite that line and put document.getElementById("demo").innerHTML = header; right after header=xhttp.getAllResponseHeaders(); or use https://javascript.info/async-await Edited May 26, 2021 by bogQ Letraindusoir 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Developers Jos Posted May 26, 2021 Developers Posted May 26, 2021 (edited) What does this thread have to do with AutoIt3 at all, so why post the quest here? Jos moved Edited May 26, 2021 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Letraindusoir Posted May 27, 2021 Author Posted May 27, 2021 15 hours ago, bogQ said: Note that your question is on wrong place, this is autoit help and support part of forum, not a javascript support . The two are not contradictory. some au3-udf related to web page operations such as IE.au3,selenium, sometimes need to introduce JS with execScript or eval. Learn from each other and Perfect it together...
Letraindusoir Posted May 27, 2021 Author Posted May 27, 2021 16 hours ago, bogQ said: You can change global variable data or object and set new data or even better make a return if that is available. Note that your question is on wrong place, this is autoit help and support part of forum, not a javascript support . https://stackoverflow.com/a/7744623/1775164 Note that your calling innerHTML = arh; probably before data is fetched, so delite that line and put document.getElementById("demo").innerHTML = header; right after header=xhttp.getAllResponseHeaders(); or use https://javascript.info/async-await Search from web, some say that it can work if change the asynchronous submission to synchronous submission. more thanks!
Moderators JLogan3o13 Posted May 27, 2021 Moderators Posted May 27, 2021 13 hours ago, Letraindusoir said: Learn from each other and Perfect it together... Much like asking a Toyota group about why your Ford won't start. Just because they are both car groups doesn't mean you're asking the question in the right place. Earthshine 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now