javascript可以向服务器提交表单数据吗?
传的格式是http://xxx.cgi?id=1&&ip=192.168.1.10 这种的要怎么做呢?
比如:
<form name="form1" action="kong.htm" method="get">
userName:<input id="name" type="text" /><br /><br />
password:<input id="Text1" type="text" /><br /><br />
<input id="Submit1" type="submit" value="submit"/>怎么用获取username和password的值 传给服务器呢?javascript服务器
传的格式是http://xxx.cgi?id=1&&ip=192.168.1.10 这种的要怎么做呢?
比如:
<form name="form1" action="kong.htm" method="get">
userName:<input id="name" type="text" /><br /><br />
password:<input id="Text1" type="text" /><br /><br />
<input id="Submit1" type="submit" value="submit"/>怎么用获取username和password的值 传给服务器呢?javascript服务器
document.getElementById("Submit1").click();
document.forms[0].submit();
或
document.getElementsByTagName('form')[0].submit();
或
document.getElementById('xxx').submit();
type: "GET",
url: "文件名.php",
dataType: "JSON",//**注意:加这段就不能alert内容,因为echo没有加上json_encode
data: {参数名:值},//{}这样写就是Json数据;
error:function(e){
alert("error occured");//有错误时候会弹出该信息;
},
success: function(msg){
}
)};
直接创建个img标签就好了
new Image().src= "http://xxx.cgi?name=n&password=p"
参数要encodeURIComponent