ปลั๊กอินสำหรับ jQuery ในการ ส่งค่าตัวแปลพร้อมกับ redirect ไปยังหน้าที่ต้องการใช้ได้ทั้ง GET , POST
Syntax
1 2 3 4 5 6 7 8 9 |
/** * jQuery Redirect * @param {string} url - Url of the redirection * @param {Object} values - (optional) An object with the data to send. If not present will look for values as QueryString in the target url. * @param {string} method - (optional) The HTTP verb can be GET or POST (defaults to POST) * @param {string} target - (optional) The target of the form. If you set "_blank" will open the url in a new window. * @param {boolean} traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array. This allows arrays to work with MVC.net among others. */ $.redirect(url, [values, [method, [target, [traditional]]]) |
ตัวอย่าง
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<html> <head> <!-- other headers --> <script src="jquery-XXX.js"></script> <script src="jquery.redirect.js"></script> <script> jQuery(function($){ //OnClick testButton do a POST to a login.php with user and pasword $("#testButton").click(function(){ $.redirect("/login.php",{ user: "johnDoe", password: "12345"}); }); } </script> </head> <body> <button id="testButton">Test Redirect</button> </body> </html> |
ดาวน์โหลดและดูรายละเอียดเพิ่มเติม https://github.com/mgalante/jquery.redirect