我正在使用jquery post发送一些值给服务器端。作为回应,我收回字符串。然后,我正在使用它并通过使用JSON.parse()转换成一个对象...当我在查看控制台日志时,我看到了对象,这对我来说看起来很好。现在当我试图循环对象并试图检索值时,我无法遍历它。我不知道我在这里错过了什么。我上的变化上发送的值event..so基本for循环的变化事件无法循环访问对象
这里运行每次都是我的js
$(function(){
var categoryChoiceVal = '';
var x = [];
var html = '';
$('select').change(function() {
categoryChoiceVal = $('.categoryChoice option:selected').text().replace(/ /g, '%20');
$.post("ajax.php", { categoryChoiceVal:categoryChoiceVal},function(data) {
x = $.parseJSON(data)
console.log(x);
});
$.each(x, function(){
html += this.address;
});
$('.dataContainer').html(html);
});
});
这里是我做的这个页面。 http://soumghosh.com/otherProjects/phpDataOperation/eventcCalendar/testOne.php
同一问题每天要问十次。可能重复的[如何从AJAX调用返回响应?](http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call) – meagar