{"id":26491,"date":"2021-04-26T23:10:06","date_gmt":"2021-04-27T03:10:06","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/ajax-basic-operations-programming-code-examples-null\/"},"modified":"2021-04-26T23:10:06","modified_gmt":"2021-04-27T03:10:06","slug":"ajax-basic-operations-programming-code-examples-null","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26491","title":{"rendered":"Ajax Basic Operations #Programming Code Examples #NULL"},"content":{"rendered":"<pre style='font-size:15px;padding:10px'>\n\nGet a handle to XMLHttpRequest object\n\n function getAjaxObject(){\n\n    var ajaxObject = false;\n\n    if (window.XMLHttpRequest){\n\n         ajaxObject = new XMLHttpRequest();\n\n    }else if (window.ActiveXObject) {\n      try{\n        ajaxObject = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);\n\n      }catch(e){\n         try{\n          ajaxObject = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);\n\n         }catch(e){\n           ajaxObject = false;\n\n         }\n\n      }\n    }\n    return ajaxObject; \n\n  }\n\n\n\nuse of onreadystatechange\n\nif (ajaxObject){\n\/\/takeAction - reference to a function\n   ajaxObject.onreadystatechange = takeAction; \n}\n\n\n\nSample code:\n\n var ajaxObject = getAjaxObject();\n\n if (ajaxObject ){\n    ajaxObject.onreadystatechange = takeAction; \n\n    ajaxObject.open(&quot;POST&quot;,&quot;file.jsp&quot;, true);\n\n    ajaxObject.setRequestHeader(&quot;Content-type&quot;, &quot;application\/x-www-form-urlencoded&quot;);\n\n    ajaxObject.send(&quot;id=500&amp;name=keith&amp;age=18&quot;);\n\n }\n\n\n\nfunction takeAction(ajaxObject){\n  if (ajaxObject.readyState == 4) {\n\n     \/\/do something with the response\n  }\n }\n\n\nfunction takeAction(ajaxObject){\n\n  if (ajaxObject.readyState == 4) {\n\n     if (ajaxObject.status == 200 || ajaxObject.status == 304){ \/\/response was sent succesfully \n\n          \/\/do something with the response\n     }\n  }\n }\n\n\n\nfunction takeAction(ajaxObject){\n  if (ajaxObject.readyState == 4) {\n\n     if (ajaxObject.status == 200 || \najaxObject.status == 304){ \n\/\/response was sent succesfully \n\n          \/\/do something with the response\n          alert(ajaxObject.responseText);\n\n     }\n  }\n }\n\n\n\n\n\n\nfunction getAjaxObject(){\n    var ajaxObject = false;\n    if (window.XMLHttpRequest){\n\n         ajaxObject = new XMLHttpRequest();\n    }else if (window.ActiveXObject) {\n\n      try{\n        ajaxObject = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);\n\n      }catch(e){\n         try{\n          ajaxObject = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);\n\n         }catch(e){\n           ajaxObject = false;\n         }\n\n      }\n    }\n    return ajaxObject; \n  }\n\n  function entryPoint(){\n\n    var ajaxObject = getAjaxObject();\n\n     if (ajaxObject ){\n    ajaxObject.onreadystatechange = function(){\n\n      takeAction(ajaxObject); \n    };\n    ajaxObject.open(&quot;POST&quot;,&quot;file.jsp&quot;, true);\n\n    ajaxObject.setRequestHeader(&quot;Content-type&quot;, &quot;application\/x-www-form-urlencoded&quot;);\n\n    ajaxObject.send(&quot;id=500&amp;name=keith&amp;age=18&quot;);\n\n }\n }\n function takeAction(ajaxObject){\n  if (ajaxObject.readyState == 4) {\n\n     if (ajaxObject.status == 200 || ajaxObject.status == 304){\n \/\/response was sent succesfully \n\n          \/\/do something with the response\n          alert(ajaxObject.responseText);\n\n          var testDiv = document.getElementById(&quot;test&quot;);\n\n          testDiv.innerText = ajaxObject.responseText; \n\n     }\n  }\n }\n\n\n\nProcessing Response Data:\n\nvar data = ajaxObject.responseXML;\n\ndata.getElementsByTagName(&quot;name&quot;)\n\ndata.getElementsByTagName(&quot;name&quot;)[0]\n\ndata.getElementsByTagName(&quot;name&quot;)[0].firstChild\n\ndata.getElementsByTagName(&quot;name&quot;)[0].firstChild.nodeValue\n\n\nJSON Example:\n\n{&quot;person&quot;:{ &quot;name&quot;:&quot;Keith Tang&quot;, &quot;school&quot;:&quot;uofm&quot; } } \n\nvar data = eval('('+ ajaxObject.responseText +')');\nvar name = data.person.name;\nvar school = data.person.school; \n\n\n\nif (ajaxObject.status == 200 || ajaxObject.status == 304){ \n\/\/response was sent succesfully \n          \/\/do something with the response\n\n          alert(ajaxObject.responseText);\n          var testDiv = document.getElementById(&quot;test&quot;);\n\n          testDiv.innerHTML = ajaxObject.responseText; \n\n     }\n\n\n\n\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10177<br \/> Categories:Programming Code Examples, NULL<br \/>Tags:NULL<br \/> Post Data:2017-01-02 16:04:23<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Get a handle to XMLHttpRequest object function getAjaxObject(){ var ajaxObject = false; if (window.XMLHttpRequest){ ajaxObject = new XMLHttpRequest(); }else if (window.ActiveXObject) { try{ ajaxObject = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;); }catch(e){ try{ ajaxObject = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); }catch(e){ ajaxObject = false; } } } return ajaxObject; } use of onreadystatechange if (ajaxObject){ \/\/takeAction &#8211; reference to a function ajaxObject.onreadystatechange &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26491\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-26491","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":62227,"url":"http:\/\/bangla.sitestree.com\/?p=62227","url_meta":{"origin":26491,"position":0},"title":"Ajax: Basic Operations Code #Programming Code Examples #Ajax #Ajax","author":"Author-Check- Article-or-Video","date":"May 15, 2021","format":false,"excerpt":"Get a handle to XMLHttpRequest object function getAjaxObject(){ var ajaxObject = false; if (window.XMLHttpRequest){ ajaxObject = new XMLHttpRequest(); }else if (window.ActiveXObject) { try{ ajaxObject = new ActiveXObject(\"Msxml2.XMLHTTP\"); }catch(e){ try{ ajaxObject = new ActiveXObject(\"Microsoft.XMLHTTP\"); }catch(e){ ajaxObject = false; } } } return ajaxObject; } use of onreadystatechange if (ajaxObject){ \/\/takeAction -\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":24404,"url":"http:\/\/bangla.sitestree.com\/?p=24404","url_meta":{"origin":26491,"position":1},"title":"Ajax: An Overview #Root","author":"Author-Check- Article-or-Video","date":"April 8, 2021","format":false,"excerpt":"Ajax: dynamically changes a portion of the current web-page without refreshing t he total web-page. Resembles the way IFrame works. So far I know, google uses IFrame to display\/refresh maps in web-pages XMLHttpRequest is the object that serves the purpose of Ajax The way it works: create an instance of\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":68909,"url":"http:\/\/bangla.sitestree.com\/?p=68909","url_meta":{"origin":26491,"position":2},"title":"Ajax: An Overview #65","author":"Author-Check- Article-or-Video","date":"August 8, 2021","format":false,"excerpt":"Ajax: dynamically changes a portion of the current web-page without refreshing the total web-page. Resembles the way IFrame works. So far I know, google uses IFrame to display\/refresh maps in web-pages XMLHttpRequest is the object that serves the purpose of Ajax The way it works: create an instance of the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65804,"url":"http:\/\/bangla.sitestree.com\/?p=65804","url_meta":{"origin":26491,"position":3},"title":"JavaScript &#8211; Miscellaneous Validations #JavaScript","author":"Author-Check- Article-or-Video","date":"July 15, 2021","format":false,"excerpt":"function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } \/\/not 100% right, will fix later function checkDateFormat() { var pattern = new RegExp(0|1[0-9]\/[0-3][0-9]\/[0-9][0-9]); if(document.getElementById('timestampStarted').value.match(pattern)) { var date_array = document.getElementById('timestampStarted').value.split('\/'); var month = date_array[0]; var day = date_array[1]; var year = date_array[2]; \/\/ This instruction will\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70135,"url":"http:\/\/bangla.sitestree.com\/?p=70135","url_meta":{"origin":26491,"position":4},"title":"JavaScript &#8211; Miscellaneous Validations #13","author":"Author-Check- Article-or-Video","date":"August 27, 2021","format":false,"excerpt":"function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } function validateDomainName(strValue) { return \/www.[a-z0-9_-]+.[a-z]{2, 3}\/ig.test(strValue); } \/\/not 100% right, will fix later function checkDateFormat() { var pattern = new RegExp(0|1[0-9]\/[0-3][0-9]\/[0-9][0-9]); if(document.getElementById('timestampStarted').value.match(pattern)) { var date_array = document.getElementById('timestampStarted').value.split('\/'); var month = date_array[0]; var day = date_array[1]; var year = date_array[2]; \/\/ This instruction will\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65806,"url":"http:\/\/bangla.sitestree.com\/?p=65806","url_meta":{"origin":26491,"position":5},"title":"JavaScript Codes #JavaScript","author":"Author-Check- Article-or-Video","date":"July 15, 2021","format":false,"excerpt":"JavaScript is a very powerful scripting language for web-site development. Also, it is in much demand. var serviceInstancesArrAtLoad = Array(); var serviceInstancesArrAtSubmit = Array(); var tempArr=Array(); function validate_required(field,alerttxt) { with (field) { if (value==null||value=='') { alert(alerttxt);return false } else {return true} } } function validateTicketCreateForm(thisform) { with (thisform) { if\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26491"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26491\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26491"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}