I'm trying to direct a browser to a different page.
(我正在尝试将浏览器定向到其他页面。)
If I wanted a GET request, I might say(如果我想要一个GET请求,我可能会说)
document.location.href = 'http://example.com/q=a';
But the resource I'm trying to access won't respond properly unless I use a POST request.
(但是我试图访问的资源不会正常响应,除非我使用POST请求。)
If this were not dynamically generated, I might use the HTML(如果这不是动态生成的,我可能会使用HTML)
<form action="http://example.com/" method="POST">
<input type="hidden" name="q" value="a">
</form>
Then I would just submit the form from the DOM.
(然后我只需从DOM提交表单。)
But really I would like JavaScript code that allows me to say
(但实际上我想要允许我说的JavaScript代码)
post_to_url('http://example.com/', {'q':'a'});
What's the best cross browser implementation?
(什么是最好的跨浏览器实现?)
Edit
(编辑)
I'm sorry I was not clear.
(对不起,我不清楚。)
I need a solution that changes the location of the browser, just like submitting a form.(我需要一个改变浏览器位置的解决方案,就像提交表单一样。)
If this is possible with XMLHttpRequest , it is not obvious.(如果使用XMLHttpRequest可以实现这一点,那就不明显了。)
And this should not be asynchronous, nor use XML, so Ajax is not the answer.(这不应该是异步的,也不应该使用XML,所以Ajax不是答案。)
ask by Joseph Holsten translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…