通过form.submit()的JS POST请求与点击一不同

时间:2013-07-17 16:09:17

标签: javascript windows google-chrome post request

我需要使用javascript提交post方法表单,这是表单:

<form action="" method="POST">
  <p>
    <input class="button white bigwidth" type="submit" name="imgContinue" value="Continue to image ... ">
  </p>
</form>

这就是我尝试通过JS发送它的方式:

var form = document.getElementsByTagName("form");
if(form.length != 0) {
  form[0].submit();
}

但它的工作方式与单击按钮的方式不同(我检查过只有一个jquery点击处理程序)

测试页:http://imgmoney.com/img-515f13c1bb27c.html

如何以与用户鼠标点击相同的方式自动发送表单的任何建议吗?

通过form.submit()

请求
POST http://imgmoney.com/img-515f13c1bb27c.html HTTP/1.1
Host: imgmoney.com
Connection: keep-alive
Content-Length: 0
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://imgmoney.com
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://imgmoney.com/img-515f13c1bb27c.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: PHPSESSID=b9ef96omfovrk66op827t1sim3; HstCfa2204047=1374076305244; HstCmu2204047=1374076305244; Cls_weather=low%7Bundefined%7Dhigh%7Bundefined%7Dicon%7Bundefined%7Dcondition%7Bundefined%7Dbase%7Bhttp%3A//www.google.com%7Dsug_unit%7BC%7Dcity%7BSaint%20Petersburg%7Dcountry%7BRU%7D; __atuvc=2%7C29; noadvtday=0; ao_s=7; HstCla2204047=1374076527809; HstPn2204047=7; HstPt2204047=7; HstCnv2204047=1; HstCns2204047=1; MLRV_72204047=1374076528372; MLR72204047=1374076518000; __utma=24314786.908711371.1374076306.1374076306.1374076306.1; __utmb=24314786.7.10.1374076306; __utmc=24314786; __utmz=24314786.1374076306.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

并通过用户点击鼠标

POST http://imgmoney.com/img-515f13c1bb27c.html HTTP/1.1
Host: imgmoney.com
Connection: keep-alive
Content-Length: 34
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://imgmoney.com
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://imgmoney.com/img-515f13c1bb27c.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: PHPSESSID=b9ef96omfovrk66op827t1sim3; HstCfa2204047=1374076305244; HstCmu2204047=1374076305244; Cls_weather=low%7Bundefined%7Dhigh%7Bundefined%7Dicon%7Bundefined%7Dcondition%7Bundefined%7Dbase%7Bhttp%3A//www.google.com%7Dsug_unit%7BC%7Dcity%7BSaint%20Petersburg%7Dcountry%7BRU%7D; __atuvc=2%7C29; noadvtday=0; ao_s=8; HstCla2204047=1374076561596; HstPn2204047=8; HstPt2204047=8; HstCnv2204047=1; HstCns2204047=1; __utma=24314786.908711371.1374076306.1374076306.1374076306.1; __utmb=24314786.8.10.1374076306; __utmc=24314786; __utmz=24314786.1374076306.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); MLRV_72204047=1374076562369; MLR72204047=1374076555000

imgContinue=Continue+to+image+...+

我需要通过JS做任何建议吗?

0 个答案:

没有答案