【发布时间】:2012-03-06 17:24:29
【问题描述】:
我正在使用淘汰赛,我正在尝试将信息发送到 PHP,使用 firebug 来检查网络 -> 标题我有这个:
Request URL:http://localhost/loyalty/welcome/json/
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:85
Content-Type:application/json
Host:localhost
Origin:http://localhost
Referer:http://localhost/loyalty/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11
X-Requested-With:XMLHttpRequest
Request Payload
{"friends":[{"name":"name","isOnTwitter":false},{"name":"name","isOnTwitter":false}]}
Response Headersview source
Connection:Keep-Alive
Content-Length:0
Content-Type:text/html
Date:Wed, 15 Feb 2012 11:01:23 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By:PHP/5.3.8
生成的 JSON 是:{"friends":[{"name":"name","isOnTwitter":false},{"name":"name","isOnTwitter":false}]},我不知道如何获取这些值。
这是 Ajax 调用:
save: function() {
$.ajax({
url:"http://localhost/loyalty/welcome/json/",
type: "post",
data: ko.toJSON(this),
contentType: "application/json",
success: function (result) {
alert(result);
}
});
在我的 CodeIgniter 方法中,我尝试使用 $this->input->post('friends') 以及我能想到的任何其他方法接收它,但没有任何结果。
【问题讨论】:
标签: php ajax json knockout.js