首页 文章

获取内容长度但没有内容

提问于
浏览
0

我正在发送带有数据的POST请求,但我没有收到任何数据 .

致电请求:

$.ajax({
    type:"POST",
    url:"ajaxtest.lp",
    dataType:'json',
    contentType:'json',
    data:"{name:'lolbert',surname:'roflcopter'}"
})

会发生什么:

HEADER:

Connection  
close
Content-Type    
text/html
Date    
Thu, 01 Jan 1970 07:24:40 GMT
Server  
Core4Web
Quelltext anzeigen
Accept  
application/json, text/javascript, */*; q=0.01
Accept-Encoding 
gzip, deflate
Accept-Language 
de,en-US;q=0.7,en;q=0.3
Content-Length  
31
Content-Type    
json; charset=UTF-8
Host    
192.168.207.117
Referer 
http://192.168.207.117/ajaxtest.lp
User-Agent  
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0
X-Requested-With    
XMLHttpRequest

POST (via Firebug):

name=lolbert&surname=roflcopter

但我在服务器端收到的东西有点奇怪 . 内容长度是正确的(37个字符),但内容本身缺失 .

****请求script_file请求script_file ajaxtest.lp client_content_type请求client_content_type json; charset = UTF-8 client_port请求client_port 64626方法请求方法post client_address请求client_address 192.168.203.59 client_content_length请求client_content_length 37 urn请求urn /ajaxtest.lp script_vpath请求script_vpath /ajaxtest.lp script_path请求script_path /usr/lib/htdocs/ajaxtest.lp script_pdir请求script_pdir / usr / lib / htdocs / script_vdir请求script_vdir / ****标头Content-Type标头Content-Type json; charset = UTF-8 Accept-Encoding标头Accept-Encoding gzip,deflate X-Requested-With header X-Requested-With XMLHttpRequest Accept-Language header Accept-Language de,en-US; q = 0.7,en; q = 0.3 Connection header Connection keep-alive Pragma header Pragma no-cache Content-Length header Content-Length 37主机头Host 192.168.207.117 User-Agent header User-Agent Mozilla / 5.0(Windows NT 6.1; WOW64; rv:42.0)Gecko / 20100101 Firefox /42.0接受 Headers 接受application / json,text / javascript,/; q = 0.01 Referer header Referer http://192.168.207.117/ajaxtest.lp Cache-Control header Cache-Control no-cache **** file script_path file script_path /usr/lib/htdocs/ajaxtest.lua script_pdir file script_pdir / usr / lib / htdocs / urn文件urn ajaxtest.lua script_vpath文件script_vpath /ajaxtest.lua nesting_level文件nesting_level 1 script_file文件script_file ajaxtest.lua script_vdir文件script_vdir /

2 回答

  • 0

    不是正确的JSON数据:http://www.json.org/试试:

    data: '{"name": "lolbert","surname": "roflcopter"}'
    

    您可以使用在线工具检查正确的JSON格式(例如http://jsonlint.com/) .

  • 0
    $.ajax({
        type:"POST",
        url:"ajaxtest.lp",
        dataType:'json',
        contentType:'json',
        data:{name:'lolbert',surname:'roflcopter'}
    });
    

    请尝试使用对象发送数据 .

相关问题