DataProcessor and failed XML response

Hi Everybody,

Please help me with response in xml with update status, after changes on grid. Everythings looks very simple.

  1. I have file with declarations of dhtmlxlayout, grid, dataprocessor (php)
  2. Anoteher file make changes in sql database after receive data from first file

Code of this two files
First file (it’s part of php code)

<script>
var ".$UniqueName." = new dhtmlXLayoutObject(document.body, '2E');
var ".$UniqueName."_cellA = ".$UniqueName.".cells('a');
".$UniqueName."_cellA.setHeight(60);
".$UniqueName."_cellA.hideHeader();
".$UniqueName."_cellA.setText(\"Informacje ogólne\");
var ".$UniqueName."_cellB = ".$UniqueName.".cells('b');
".$UniqueName."_cellB.hideHeader();

var toolbar = ".$UniqueName.".attachToolbar();
toolbar.setIconsPath(\"imgs/\");
toolbar.addButton(\"save\", 0, \"Zapisz zmiany\", \"save.gif\", \"save_dis.gif\");
toolbar.addButton(\"refresh\", 1, \"Odśwież bez zapisywania\", \"redo.gif\", \"redo_dis.gif\");

toolbar.attachEvent(\"onClick\", function(id,ind){
	if (id == 'refresh') {
		".$UniqueName."_cellB_Tabbar_Assumption.clearAndLoad(\"LoadBudgetGridPCCEditRea.php?ID=".$ID."\",\"jsarray\");
	} else if (id == 'save') {
		dp.sendData();
	}
	
});

var ".$UniqueName."_cellB_Tabbar_Assumption = ".$UniqueName."_cellB.attachGrid();
".$UniqueName."_cellB_Tabbar_Assumption.setImagePath(\"imgs/\");
".$UniqueName."_cellB_Tabbar_Assumption.setHeader(\"ID,Grupa,Nr,Składnik,Styczeń,Luty,Marzec,Kwiecień,Maj,Czerwiec,Lipiec,Sierpień,Wrzesień,Pażdziernik,Listopad,Grudzień\");
".$UniqueName."_cellB_Tabbar_Assumption.setInitWidths(\"30,100,30,160,".str_repeat('80,',11)."80\");
".$UniqueName."_cellB_Tabbar_Assumption.setColAlign(\"right,left,left,left,".str_repeat('right,',11)."right\");
".$UniqueName."_cellB_Tabbar_Assumption.setColTypes(\"ro,ro,ro,ro,".str_repeat('price,',11)."price\");
".$UniqueName."_cellB_Tabbar_Assumption.init();
".$UniqueName."_cellB_Tabbar_Assumption.load(\"LoadBudgetGridPCCEditRea.php?ID=".$ID."\",\"jsarray\");
var dp = new dataProcessor(\"PCCData_Assumption_Save.php\");
dp.setTransactionMode(\"POST\", true);
dp.setUpdateMode(\"off\");
dp.init(".$UniqueName."_cellB_Tabbar_Assumption);

</script>

… and the second file

<?php
header("Content-type: text/xml");

echo('<?xml version="1.0" encoding="utf-8"?>'); 
require_once("../conf.php");
require_once("../require.php");

function add_row($rowId){
     global $newId;
    
     return "insert";     
}

function update_row($rowId){
     return "update";     
}

function delete_row($rowId){
     return "delete";
}

echo "<data>";
$ids = explode(",",$_POST["ids"]);

for ($i=0; $i < sizeof($ids); $i++) { 
     $rowId = $ids[$i]; //id or row which was updated 
     $newId = $rowId; //will be used for insert operation     
     $mode = $_POST[$rowId."_!nativeeditor_status"]; //get request mode

     switch($mode){
          case "inserted":
               //row adding request
               $action = add_row($rowId);
          break;
          case "deleted":
               //row deleting request
               $action = delete_row($rowId);
          break;
          default:
               //row updating request
               $action = update_row($rowId);
          break;
     }
     echo "<action type='".$action."' sid='".$rowId."' tid='".$newId."'/>";
     
}

echo "</data>";

?>

Second file is now easiest as can be… I’ve delete everything except simple update function (BTW it’s copy of file from documentation)

Anyway… When I send data to second file I receive an error like in attachments (1.jpg). FireBug show correct response (?). Anyway when I click on XML in firebug report it show something like on the second attachment… In English it is something like: Error XML processing: incorrect area format: moz-nullprincipal:{6f5b22a9-e8ff-4dc2-adc9-8b0d62e5f386} Row No: 1, column 39: (…)

Where is the problem with XML?

Regards,
Czarek




Hi,
could you provide source code of response (tab Odpowiedz if I don’t miss anything)?
By the way, you may use dhtmlxConnector for server side operations.
It will generates xml to load data and process all edit requests itself:
dhtmlx.com/docs/products/dhtmlxC … ndex.shtml

Hi Radyno,

You can see the xml response on first attachment (1.jpg).
<?xml version=“1.0” encoding=“utf-8”>

Maybe it will be important- when I replace the PCCData_Assumption_Save.php with xml file with identical text like response in attachment
<?xml version=“1.0” encoding=“utf-8”>,
update process run correctly and row on the grid is updated properly…

But… I still can’t find a way to update grid with this php file.

BTW. Thanks for dhtmlxConnector proposition. But now I must build aplication without it, maybe in future it will be a good idea :slight_smile:

Regards,
T.

Please, make sure that response has Content-type: text/xml.
It looks like that there are some problems here.
Response format is correct and it should work.
Maybe php-code contains any empty lines before <?php tag?