我希望能夠自動提交表單(通用表單,供用戶跟蹤)。如何使用javascript自動提交表單(onevent)?
例如,創建一個POST到 http://www.example.com/index.php?option=track&variable=variable 應用程序/ x-WWW窗體-urlencoded有東西像
username=usernamestring
otherdata=otherdata_string
otherdata2=otherdata string 2
實際字符串將預先格式化,不過,因爲所有它就像一個'平」。 它需要提交onevent,與外部js(http://example.com/scripts/js.js)
我應該幹什麼?這變得很煩人。
更新:我想我並沒有真正說清楚;我有一個不應該在頁面上顯示的預製表單;它需要提交一個事件。表單域不存在於頁面上;我所做的只是鏈接到頁面上的腳本,並執行onLoad。
POST uri:http://www.example.com/index.php?option=track&variable=variable 上面的參數(option = track和variable = variable)不是表單詳細信息(postdata)。
內容類型爲application/x-www-form-urlencoded,並具有以下鍵/值。
username=usernamestring
otherdata=otherdata_string
otherdata2=otherdata string 2 (when encoded, the spaces get turned to %20's.)
我需要一個腳本,在運行時提交此腳本。
謝謝,希望我早點被告知。雖然有時候並不總能得到足夠的答案,但我通常會很好。 – 2012-01-15 15:40:13
請參閱http://stackoverflow.com/questions/4484517/submit-form-via-javascript – erikxiv 2012-01-15 16:03:37
這並沒有解決..我沒有我的答案。 – 2012-01-15 21:03:06