基本上,我想做的就是POST在更改時(shí)發(fā)送數(shù)據(jù)window.location,就好像用戶已提交表單并將其轉(zhuǎn)到新頁面一樣。我需要這樣做,因?yàn)槲倚枰獋鬟f一個(gè)隱藏的URL,并且GET出于美觀原因,我不能簡單地將其放置在URL中。這是我目前所擁有的,但是它不發(fā)送任何POST數(shù)據(jù)。if(user has not voted) { window.location = 'http://example.com/vote/' + Username;}我知道您可以使用發(fā)送POST數(shù)據(jù)jQuery.post(),但是我需要將其與新數(shù)據(jù)一起發(fā)送window.location。因此,回顧一下,我需要通過發(fā)送api_url值POST到http://example.com/vote/,同時(shí)將用戶發(fā)送到同一頁面。為了將來參考,我最終做了以下工作:if(user has not voted) { $('#inset_form').html('<form action="http://example.com/vote/' + Username + '" name="vote" method="post" style="display:none;"><input type="text" name="api_url" value="' + Return_URL + '" /></form>'); document.forms['vote'].submit();}
使用JavaScript / jQuery發(fā)送有關(guān)重定向的POST數(shù)據(jù)?
繁星點(diǎn)點(diǎn)滴滴
2019-10-15 14:08:21