Dont use JSON anymore, we really dont need the entire report object, we just need the 3 fields type, stock and desc, so return them on their own line, so we can just split on \n

This commit is contained in:
james 2007-12-20 18:13:06 +00:00
parent f17f07ff94
commit 515a92dda7
2 changed files with 35 additions and 2 deletions

View File

@ -32,8 +32,14 @@
if($reports_id > 0) {
$report = report_load($reports_id);
echo json_encode($report);
echo $report['type']."\n";
echo $report['stock']."\n";
echo $report['desc']."\n";
// echo json_encode($report);
}
else
echo json_encode(array());
{
echo "\n\n\n";
// echo json_encode(array());
}
?>

View File

@ -239,6 +239,7 @@
document.getElementById('reporttypecustom').style.display='none';
document.getElementById('reportstockcustom').style.display='none';
/* dont use JSON anymore since it adds an extra PHP-side requirement, we'll just get a 3 line response with one thing per line that we need
var obj=eval('('+http.responseText+')');
if(obj['option']['type']) {
for(i=0;i<document.addreport.type.options.length;i++) {
@ -260,6 +261,32 @@
if(obj['desc'])
document.addreport.comment.value=obj['desc'];
*/
var lines=http.responseText.split('\n');
var reportType=lines[0];
var reportStock=lines[1];
var reportDesc=lines[2];
if(reportType) {
for(i=0;i<document.addreport.type.options.length;i++) {
if(document.addreport.type.options[i].value==reportType)
document.addreport.type.selectedIndex=i;
}
}
else
document.addreport.type.selectedIndex=0;
if(reportStock) {
for(i=0;i<document.addreport.stock.options.length;i++) {
if(document.addreport.stock.options[i].value==reportStock)
document.addreport.stock.selectedIndex=i;
}
}
else
document.addreport.stock.selectedIndex=0;
if(reportDesc);
document.addreport.comment.value=reportDesc;
}
else
{