这是我的javascript:
function sendAttack(attacker,defender,hpChange){
USER_LAST_TIMESTAMP = Math.round(new Date().getTime() / 1000.0);
var attack = new Attack(TURN_ID,attacker,defender,hpChange);
attack.action_sequence = ACTION_QUEUE;
var attackJSON = JSON.stringify(attack);
jQuery.ajax({
type: "POST",
url: urlLeader + "attacks.json",
data: attackJSON,
success: function(data){
ACTION_QUEUE++;
}
})
}
在setup.js
上面加载之前:
jQuery.ajaxSetup({
accepts: 'application/json',
dataType: 'jsonp'
});
这是我调用该函数时服务器收到的内容:
2012-04-26T03:57:44+00:00 app[web.1]: Started GET "/attacks.json?callback=jQuery17103089843031743851_1335412646794&{%22attacker%22:2,%22defender%22:3,%22hp_change%22:6.799999999999997,%22action_sequence%22:0}&_=1335412659141" for 167.206.19.130 at 2012-04-26 03:57:44 +0000
不是“获取”。这里发生了什么?