我尝试将带有Ajax请求的两个变量发送到ajax.php
:
var xhReq = new XMLHttpRequest();
xhReq.open ( "GET", "ajax.php", false );
xhReq.setRequestHeader ("Content-type", "application/x-www-form-urlencoded");
xhReq.send ("cmd=ping&url=www.google.com");
我怎样才能做到这一点?
答案 0 :(得分:1)
你正在混合一些值。
GET请求:
xhReq.open( "GET", "ajax.php?cmd=ping&url=www.google.com", true );
xhReq.send();
POST请求:
xhReq.open( "POST", "ajax.php", true );
xhReq.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
xhReq.send( "cmd=ping&url=www.google.com" );