相关疑难解决方法(0)

如何将数据作为表单数据而不是请求有效负载发布?

在下面的代码中,AngularJS $http方法调用URL,并将xsrf对象作为"请求有效负载"提交(如Chrome调试器网络选项卡中所述).jQuery $.ajax方法执行相同的调用,但将xsrf提交为"Form Data".

如何让AngularJS将xsrf作为表单数据而不是请求有效负载提交?

var url = 'http://somewhere.com/';
var xsrf = {fkey: 'xsrf key'};

$http({
    method: 'POST',
    url: url,
    data: xsrf
}).success(function () {});

$.ajax({
    type: 'POST',
    url: url,
    data: xsrf,
    dataType: 'json',
    success: function() {}
});
Run Code Online (Sandbox Code Playgroud)

ajax post angularjs angular-http

517
推荐指数
12
解决办法
39万
查看次数

Javascript对象的查询字符串编码

您是否知道将Javascript对象编码为string可以通过GET请求传递的快速而简单的方法?

jQuery,没有其他框架 - 只是简单的Javascript :)

javascript urlencode query-string

441
推荐指数
21
解决办法
33万
查看次数

AngularJS使用Array参数调用ajax调用

我已经看到以下SO问题通过GET请求使用AngularJS'$ http服务发送数组从Angular $ http POST传递数据数组.但那里建议的解决方案似乎对我不起作用.我特别关注数组对象.

我有以下AngularJS ajax调用数组参数

return $http({
    method: 'GET',
    url: '/api/PatientCategoryApi/PatCat',
    params: { "numbers[]": [{ First: 999, Second: 888 }]},
    headers: { 'Content-Type': 'application/Json' }
})
Run Code Online (Sandbox Code Playgroud)

该调用生成的url似乎对我不起作用.我尝试了各种params的化身,并且生成的url(通过使用fiddler得到它们)如下.

params: { numbers: JSON.stringify([{ First: 999, Second: 888 }]) },
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers=%5B%7B%22First%22:999,%22Second%22:888%7D%5D 

params: { "numbers[]": JSON.stringify([{ First: 999, Second: 888 }]) },
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers%5B%5D=%5B%7B%22First%22:999,%22Second%22:888%7D%5D 

params: { "numbers[]": [{ First: 999, Second: 888 }]},
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers%5B%5D=%7B%22First%22:999,%22Second%22:888%7D 

params: { numbers: [{ First: 999, Second: 888 }]},
http://localhost:50849/api/PatientCategoryApi/PatCat?numbers%5B%5D=%7B%22First%22:999,%22Second%22:888%7D 
Run Code Online (Sandbox Code Playgroud)

我希望网址为http:// localhost:50849/api/PatientCategoryApi/PatCat?numbers …

ajax angularjs

4
推荐指数
1
解决办法
1955
查看次数