// ajax get pentalogy function ajax_get(url,data){ var ajax=new XMLHttpRequest();
//url method , If the sending data segment format is xxx.php?name=jack&age=18, Need stitching if(data){ url+='?'; url+=data;
}else{ } ajax.open('get',url); ajax.send(); ajax.onreadystatechange=function(){
if(ajax.readyState==4&&ajax.status==200){ console.log(ajax.responseText); } } }
function ajax_post(url,data){ var ajax=new XMLHttpRequest();
ajax.open('post',url);
ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
if(data){ ajax.send(data); }else{ ajax.send(); }
ajax.onreadystatechange=function(){ if(ajax.readyState==4&&ajax.status==200){
console.log(ajax.responseText); } } } // take get and post Packaged together function
ajax_tool(url,data,method,success){ var ajax=new XMLHttpRequest();
if(method=='get'){ if(data){ url+='?'; url+=data; }else{ }
ajax.open(method,url); ajax.send(); }else{ //post The request does not need to be changed ajax.open(method,url);
ajax.setRequestHeader("Content-type","x-www-form-urlencoded"); if(data){
ajax.send(data); }else{ ajax.send(); } } ajax.onreadystatechange=function(){
if(ajax.readyState==4&&ajax.status==200){ console.log(ajax.responseText);
// Make data available to the outside world return ajax.responseText; // When onreadystatechange On call explain The data is back //
ajax.responseText; success(ajax.responseText); } } }
quote
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8">
<title>Document</title> </head> <body> <input type="button" value=" test get"
id="ajax_get"> </body> </html> <!-- Import encapsulated JS --> <script type="text/javascript"
src="ajax_tool.js"></script> <script type="text/javascript">
document.querySelector("#ajax_get").onclick=function(){ var
backData=ajax_tool('01.test_get.php','name=huluwa&&skill=saveyeye','get',function(data){
console.log(data); }); console.log(backData); } </script> <?php // obtain get Submitted data
echo $_GET['skill']; ?>

Technology
©2020 ioDraw All rights reserved
Swing actual combat Understanding closure about vue in el-date-picker type=daterange The problem of date not echoing Ubuntu 18.04 swap Partition expansion Snake code --c Language Edition visual c++6.0 open 【Golang Basic series 10 】Go language On conditional sentences ifString class —— summary ,String The nature of , Memory resolution , Commonly used APIAdobe Illustrator Publish native support Apple Silicon Test version of the software study java My first class antd table sort