-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
html5 file api相关 , HTTP请求中的form data和request payload的区别 #58
Comments
HTTP请求中的form data和request payload的区别AJAX Post请求中常用的两种传参数的形式:form data 和 request payload form dataget请求的时候,我们的参数直接反映在url里面,形式为key1=value1&key2=value2形式,比如: request payload请求的Content-Type为application/json;charset=UTF-8,而请求表单参数在Request Payload中 区别
|
为什么要设置Content-type
而GET请求提交的数据以" 常见Content-type
表单提交form表单提交时,Content-type由enctype设置: <!-- submit时页面跳转 -->
<form enctype="multipart/form-data" method="post"></form> 如果不设置 Ajax提交 Ajax的POST请求, xhr.setRequestHeader("Content-type","...") |
js模拟form表单提交 /**
* form表单提交
* @param {*} url
* @param {*} params
*/
function formPost(url, params) {
const $form = document.createElement('form');
$form.action = url;
$form.style.display = 'none';
$form.target = '_self';
$form.method = 'post';
for (let key in params) {
let $input = document.createElement('input');
$input.name = key;
$input.value = params[key];
$form.appendChild($input);
}
document.body.appendChild($form);
$form.submit();
} |
HTML5使用 JavaScript File API 实现文件上传
[JS进阶] HTML5 之文件操作(file)
javascript 使用Html5 File Api进行文件读取
还是不太熟..
通用模式,省的每次都得想下
The text was updated successfully, but these errors were encountered: