假设:
request = .ajax({
method: 'POST',
data : JSON.stringify(object),
url : 'offline_ajax_queue.php',
contentType : 'application/json',
dataType : 'json',
cache : false,
success : function(response) {
console.log(response);
for (var key in response) {
if (response.hasOwnProperty(key)) {
console.log(key, response[key]);
if(response[key] > -1)
removeAction(key);
}
}
}
});
并在控制台中,响应=
{1: 1, 2: 0, 3: 0, 4: 0}
和
typeof response[key] // "number"
为什么键string
而不是number
呢?
typeof key // "string"