$query = "SELECT Item_Name from item_details";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$optionValue[] = "<option value='" . $row['Item_Name'] . "'>" . $row['Item_Name'] . "</option>";
}
$query1 = "SELECT Item_Name from item_addon";
$result1 = mysql_query($query1);
while ($row = mysql_fetch_array($result1)) {
$optionValue1[] = "<option value='" . $row['Item_Name'] . "'>" . $row['Item_Name'] . "</option>";
}
return json_encode(array("a" => $optionValue, "b" => $optionValue1));
I need to parse the data of a
and b
我需要解析a和b的数据
optionDetails = $.parseJSON(data);
for (i = 0; i < optionDetails.length; i++) {
det_item_name = optionDetails[i];
$('#det_item_name').append(det_item_name);
}
optionAdd = $.parseJSON(data)
for (i = 0; i < optionAdd.length; i++) {
det_item_name = optionAdd[i];
$('#add_name').append(add_name);
}
How do I parse the data of a
and b
in optionDetails
and optionAdd
?
如何在optionDetails和optionAdd中解析a和b的数据?
1 个解决方案
#1
1
try this one
试试这个
var json_array = $.parseJSON(data);
var optionDetails = json_array.a;
for (i = 0; i < optionDetails.length; i++) {
det_item_name = optionDetails[i];
$('#det_item_name').append(det_item_name);
}
var optionAdd = json_array.b;
for (i = 0; i < optionAdd.length; i++) {
det_item_name = optionAdd[i];
$('#add_name').append(add_name);
}
#1
1
try this one
试试这个
var json_array = $.parseJSON(data);
var optionDetails = json_array.a;
for (i = 0; i < optionDetails.length; i++) {
det_item_name = optionDetails[i];
$('#det_item_name').append(det_item_name);
}
var optionAdd = json_array.b;
for (i = 0; i < optionAdd.length; i++) {
det_item_name = optionAdd[i];
$('#add_name').append(add_name);
}