生活 + 筆記

4.21.2010

AJAX POST, GET

POST 和 GET 傳參數時用的方法不一樣

POST

xmlhttp.open("POST",url,true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.send(string);


GET

xmlhttp.open("GET",url,true);
xmlhttp.send(null);


GET 不需要設定 Header ! send 時也不用任可參數,只要在 URL 上加上參數就可以了 ~

終於 GET 和 POST 都可以傳了 ~ 呼

沒有留言:

張貼留言