Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JSON请求头中设置参数?_Json_Rest - Fatal编程技术网

如何在JSON请求头中设置参数?

如何在JSON请求头中设置参数?,json,rest,Json,Rest,我想在JSON请求头中设置userId和密码,并在JSON请求体中设置其余参数。可以举一个例子,我如何在JSON请求头中设置userId/password,在JSON请求体中设置others参数 提前感谢。使用Jquery: <script> //submit request $.post('url',{userId: userIdvalue, Password: password value,...},function(response){ // do something when

我想在JSON请求头中设置userId和密码,并在JSON请求体中设置其余参数。可以举一个例子,我如何在JSON请求头中设置userId/password,在JSON请求体中设置others参数

提前感谢。

使用Jquery:

<script>
//submit request
$.post('url',{userId: userIdvalue, Password: password value,...},function(response){
// do something when request processed successfully
});
//if you submit a form
$.post('url',{$("#formId".serialize())},function(response){
// do something when request processed successfully
});
</script>

//提交请求
$.post('url',{userId:userIdvalue,Password:Password value,…},函数(响应){
//当请求成功处理时,请执行某些操作
});
//如果你提交一份表格
$.post('url',{$(“#formId.serialize())},函数(响应){
//当请求成功处理时,请执行某些操作
});

u可以使用poster调用该函数并设置参数。。