使用Javascript发送Get/Post请求的方法。
发送Get请求
1 2 3 4 5 6 7
| function httpGet(url) { var xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", url, false ); xmlHttp.send( null ); return xmlHttp.responseText; }
|
发送POST请求
1 2 3 4 5 6 7
| function httpPost(url) { var xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", url, false ); xmlHttp.send( null ); return xmlHttp.responseText; }
|