{"flag":true,"single":true,"pageTitle":"AJAX REQUEST Using javascript","post":{"id":213,"user_id":"1","slug":"ajax-request-using-javascript-9qny","title":"AJAX REQUEST Using javascript","body":"<pre class=\"language-markup\"><code>&lt;script&gt;\r\nfunction loadDoc() {\r\n  var xhttp = new XMLHttpRequest(); \/\/object for requests\r\n  xhttp.onreadystatechange = function() { \/\/called when the readyState property changes\r\n    if (this.readyState == 4 &amp;&amp; this.status == 200) { \/\/means responce ready &amp;&amp; status is OK\r\n      document.getElementById(\"demo\").innerHTML =\r\n      this.responseText;\r\n    }\r\n  };\r\n  xhttp.open(\"GET\", \"ajax_info9.txt\", true);\r\n  xhttp.send(); \r\n  xhttp.open(\"GET\", \"ajax_info.txt\", true);\r\n  xhttp.send();\r\n}\r\n&lt;\/script&gt;<\/code><\/pre>\r\n<ul>\r\n<li>open(method, url[, async, user, psw]); <strong>\/\/execute other scripts while waiting for server response, deal with response when ready if async is true<\/strong><\/li>\r\n<li>send(); \/\/FOR GET<\/li>\r\n<li>send(\"fname=Henry&amp;lname=Ford\"); \/\/send request for post<\/li>\r\n<\/ul>\r\n<p><strong>readyState Holds the status of the XMLHttpRequest.<\/strong><\/p>\r\n<p>0: request not initialized<\/p>\r\n<p>1: server connection established<\/p>\r\n<p>2: request received<\/p>\r\n<p>3: processing request<\/p>\r\n<p>4: request finished and response is ready<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><strong>STATUS:Returns the status-number of a request<\/strong><\/p>\r\n<p>200: \"OK\"<\/p>\r\n<p>403: \"Forbidden\"<\/p>\r\n<p>404: \"Not Found\"&nbsp;<\/p>","category_id":"12","is_private":"0","created_at":"2023-10-13T01:41:14.000000Z","updated_at":"2023-10-13T01:41:14.000000Z","category":{"id":12,"user_id":"1","name":"Javascript","slug":"javascript-xplw","parent_id":null,"created_at":"2023-03-23T02:24:43.000000Z","updated_at":"2023-03-23T02:24:43.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"&lt;script&gt; function loadDoc() {   var xhttp = new XMLHttpRequest(); \/\/object for requests   xhttp.onreadystatechange = function() { \/\/ca - AJAX REQUEST Using javascript (Updated: October 13, 2023) - Read more about AJAX REQUEST Using javascript at my programming site [SITE]","categories":[]}