Here is my JSON returned from a PHP file (just as a side note, I can use EITHER one):
// JSON Option #1:
[{"field":"title_of_production_row", "required":"1"}{"field":"where_released_row", "required":"1"}{"field":"release_date_row", "required":"1"}{"field":"running_time_row", "required":"1"}{"field":"accepting_award_row", "required":"1"}{"field":"contact_name_row", "required":"1"}{"field":"promocode_row", "required":"0"}{"field":"payment_method_row", "required":"1"}{"field":"tbl_submit", "required":"0"}{"field":"production_company_row", "required":"1"}]
// JSON Option #2: {"title_of_production_row":"1","where_released_row":"1","release_date_row":"1","running_time_row":"1","accepting_award_row":"1","contact_name_row":"1","promocode_row":"0","payment_method_row":"1","tbl_submit":"0","production_company_row":"1"}
I want to loop through each field and required, and alert them. I've tried things like:
$.ajax({
url: './ajax/get_cat_info.php?cid=' + cid,
dataType: "jason",
async: false,
success: function(html) {
alert(html);
$.each(html, function(key, val) {
alert('key: ' + key + ' - val: ' + val);
});
}
});
But this alerts individual characters. Any thoughts?
[object Object]for value. The first param passed to.each()is the current index in the each "loop", the second is the current element from the eached collection. Since the items in your array are objects, the alert casts them to string and you won't see anything of use.