Last active
February 28, 2020 15:10
-
-
Save IronGhost63/10c2071097518b7bf6e0929d8b61d264 to your computer and use it in GitHub Desktop.
upload.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery('.my-form').on('submit', (e) => { | |
e.preventDefault(); | |
let form = e.target; | |
let formData = new FormData( form ); | |
let userdata_access_token = getUserdataAccessToken(); | |
// ถ้าต้องการเพิ่มข้อมูล ใช้ .append ได้เลย | |
formData.append('userdata_access_token', userdata_access_token); | |
// แล้วเอา formData ส่งไปเป็น data ของ $.ajax | |
jQuery.ajax({ | |
url: "post-form.php", | |
type: "POST", | |
data: formData, | |
success: successCallback, // เขียน callback ตามปกติ | |
}); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment