我在使用 jQuery JSON Response 时遇到问题。我正在传递信息并取回标题,但我没有得到 HTML。我也一直在尝试用 JSONP 解决这个问题,但仍然没有结果。
<script type='text/javascript'>
$(document).ready(function(){
$("input.senddata").click(function() {
var ipForm = $('input[name="ip_submit"]').val();
var gameForm = $( 'select[name="game_submit"]' ).val()
$.getJSON("http://gamepwn.net/serversdotee/add-server.php",
{
ip: ipForm,
game: gameForm
},
function(data) {
$('#result').html(data);
});
});
});
</script>
php文件:
$data = array('items'=>array('serverip'=>'localhost', 'game'=>'cs','protocol'=>'48'));
echo json_encode($data);
我收到的标题:
Response Headers
Cache-Control no-cache, must-revalidate
Connection Keep-Alive
Content-Type application/json
Date Tue, 26 Jun 2012 21:49:01 GMT
Expires Mon, 26 Jul 1997 05:00:00 GMT
Keep-Alive timeout=5, max=100
Server Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_perl/2.0.4 Perl/v5.8.8
Transfer-Encoding chunked
X-Powered-By PHP/5.3.6
Request Headers
Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language et,et-ee;q=0.8,en-us;q=0.5,en;q=0.3
Connection keep-alive
Host gamepwn.net
Origin http://servers.kdfx.eu
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0 FirePHP/0.7.1
x-insight activate