Categories | Question details Back To List | ||
dhtmlxGrid no update with dhtmlxDataProcessor Hi all, my scripts don't update! The server response is not an xml document, but an error 404: in DataProcessor Debug I read : ****************************************************************** row 1-AD marked [updated,valid] Initiating data sending for 1-AD Sending in one-by-one mode, current ID = 1-AD Server url: update_perventivi.php parameters gr_id=1-AD c0=1 c1=AD c2=Ric c3=2009-07-01%2013%3A05%3A00 c4=%3Cb%3EPREVENTIVO%20DI%20TEST-Riccardo%3C%2Fb%3E c5=1 c6=9999 c7=%3Cb%3Etest%20riccardo%3C%2Fb%3E !nativeeditor_status=updated Server response received details <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html dir=ltr> <head> <style> a:link {font:8pt/11pt verdana; color:FF0000} a:visited {font:8pt/11pt verdana; color:#4e4e4e} </style> <META NAME="ROBOTS" CONTENT="NOINDEX"> <title>Impossibile trovare la pagina</title> <META HTTP-EQUIV="Content-Type" Content="text-html; charset=iso-8859-1"> </head> <script> function Homepage(){ <!-- // in real bits, urls get returned to our script like this: // res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm" DocURL = document.URL; //this is where the http or https will be, as found by searching for :// but skipping the res:// protocolIndex=DocURL.indexOf("://",4); //this finds the ending slash for the domain server serverIndex=DocURL.indexOf("/",protocolIndex + 3); //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker. //urlresult=DocURL.substring(protocolIndex - 4,serverIndex); BeginURL=DocURL.indexOf("#",1) + 1; urlresult=DocURL.substring(BeginURL,serverIndex); //for display, we need to skip after http://, and go to the next slash displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex); InsertElementAnchor(urlresult, displayresult); } function HtmlEncode(text) { return text.replace(/&/g, '&').replace(/'/g, '"').replace(/</g, '<').replace(/>/g, '>'); } function TagAttrib(name, value) { return ' '+name+'="'+HtmlEncode(value)+'"'; } function PrintTag(tagName, needCloseTag, attrib, inner){ document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) ); if (needCloseTag) document.write( '</' + tagName +'>' ); } function URI(href) { IEVer = window.navigator.appVersion; IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 ); return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ? encodeURI(href) : escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';'); } function InsertElementAnchor(href, text) { PrintTag('A', true, TagAttrib('HREF', URI(href)), text); } //--> </script> <body bgcolor="FFFFFF"> <table width="410" cellpadding="3" cellspacing="5"> <tr> <td align="left" valign="middle" width="360"> <h1 style="COLOR:000000; FONT: 13pt/15pt verdana"><!--Problem-->Impossibile trovare la pagina</h1> </td> </tr> <tr> <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 8pt/11pt verdana">� possibile che la pagina che si sta cercando sia stata rimossa, rinominata oppure che sia temporaneamente non disponibile.</font></td> </tr> <tr> <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 8pt/11pt verdana"> <hr color="#C0C0C0" noshade> <p>Procedere nel seguente modo:</p> <ul> <li>Se l'indirizzo della pagina � stato digitato nella barra degli indirizzi, verificare che l'indirizzo specificato sia corretto.<br> </li> <li>Aprire la <script> <!-- if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2"))) { Homepage(); } //--> </script> home page, quindi cercare i collegamenti alle informazioni desiderate.</li> <li>Fare clic clic su <a href="javascript:history.back(1)">Indietro</a> e riprovare specificando un collegamento diverso.</li> </ul> <h2 style="font:8pt/11pt verdana; color:000000">HTTP 404 - File non trovato<br> Internet Information Services<BR></h2> <hr color="#C0C0C0" noshade> <p>Informazioni tecniche (per il personale del supporto tecnico)</p> <ul> <li>Informazioni aggiuntive:<br> <a href="http://www.microsoft.com/ContentRedirect.asp?prd=iis&sbp=&pver=5.0&pid=&ID=404&cat=web&os=&over=&hrd=&Opt1=&Opt2=&Opt3=" target="_blank">Supporto Microsoft</a> </li> </ul> </font></td> </tr> </table> </body> </html> Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data ****************************************************************** My code: <script src="dhtmlxGrid/codebase/dhtmlxcommon.js"></script> <script src="dhtmlxGrid/codebase/dhtmlxgrid.js"></script> <script src="dhtmlxGrid/codebase/dhtmlxgridcell.js"></script> <script src="dhtmlxGrid/codebase/ext/dhtmlxgrid_srnd.js"></script> <script src="dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script> <!-- Ajax transaction --> <script src="dhtmlxDataProcessor/codebase/dhtmlxdataprocessor_debug.js"></script> <!-- Ajax transaction --> <script type="text/javascript"> function sortGridOnServer(ind,gridObj,direct) { mygrid.clearAll(); mygrid.loadXML(gridQString+(gridQString.indexOf("?")>=0?"&":"?")+"orderby="+ind+"&direct="+direct); mygrid.setSortImgState(true,ind,direct); return false; } function applyFilter() { mygrid.clearAll(); //remove all data gridQString = "getGridRecords.php?filter="+document.getElementById("operator_flt").childNodes[0].value.toLowerCase(); //save query string in global variable (see step 5 for details) mygrid.loadXML(gridQString); // load new dataset from sever with additional parameter passed } function doOnRowDblClicked(rowID) { window.open('preventivi.php?id='+rowID,'_blank'); } </script> <script type="text/javascript"> var mygrid; var dp; function doInitGrid() { mygrid = new dhtmlXGridObject('mygrid_container'); mygrid.setImagePath("dhtmlxGrid/codebase/imgs/"); mygrid.setHeader("ID,rev,Op,data,Note,Evas Interna,ID Cliente,Ragione Sociale"); mygrid.setInitWidths("20,25,100,120,350,50,50,*"); mygrid.setColTypes("ro,ro,ro,ro,ed,ch,ro,ro"); mygrid.setColSorting("server,server,server,server,server,server,server,server"); mygrid.attachEvent("onBeforeSorting",sortGridOnServer); mygrid.attachEvent("onRowDblClicked", doOnRowDblClicked); mygrid.setSkin("dhx_skyblue"); mygrid.setColAlign("center,center,center,center,center,center,center,center"); mygrid.init(); mygrid.enableSmartRendering(true); gridQString="getGridRecords.php"; mygrid.loadXML(gridQString); dp = new dataProcessor("update_perventivi.php"); dp.enableDebug(true); dp.init(mygrid); } </script> ****************************************************************** update_preventivi.php: <?php //code below is simplified - in real app you will want to have some kins session based autorization and input value checking error_reporting(E_ALL ^ E_NOTICE); //db connection settings mysql_pconnect("localhost", "gestionale", "opera"); mysql_select_db ("gestionale"); function update_row(){ $sql = "UPDATE preventivi SET note='".$_GET["c4"]."', evasioneInterna='".$_GET["c5"]."' WHERE ID='".$_GET["c0"]."' AND revisione='".$_GET["c1"]."';"; $res = mysql_query($sql); return "update"; } //include XML Header (as response will be in xml format) header("Content-type: text/xml"); //encoding may differ in your case echo('<?xml version="1.0" encoding="UTF-8"?>'); $mode = $_GET["!nativeeditor_status"]; //get request mode $rowId = $_GET["gr_id"]; //id or row which was updated $newId = $_GET["gr_id"]; //will be used for insert operation switch($mode){ case "inserted": //row adding request $action = add_row(); break; case "deleted": //row deleting request $action = delete_row(); break; default: //row updating request $action = update_row(); break; } //output update results echo "<data>"; echo "<action type='".$action."' sid='".$rowId."' tid='".$newId."'/>"; echo "</data>"; ?> ****************************************************************** getGridRecords.php: <?php error_reporting(E_ALL ^ E_NOTICE); header("Content-type:text/xml"); print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //define variables from incoming values if(isset($_GET["posStart"])) $posStart = $_GET['posStart']; else $posStart = 0; if(isset($_GET["count"])) $count = $_GET['count']; else $count = 10; mysql_pconnect("localhost", "gestionale", "opera"); mysql_select_db ("gestionale"); //create query to products table $sql = "SELECT ID, revisione,dataInserimento,dataRevisione,operatore,note,evasioneInterna,ID_Cliente,ragioneSociale,statoPreventivo FROM preventivi"; //query to products table if(isset($_GET["filter"])) $sql.=" WHERE operatore like '%".$_GET["filter"]."%'"; //$sql.= " GROUP BY ID "; //order by $columns = array("ID","revisione","operatore","dataInserimento","note","evasioneInterna","ID_Cliente","ragioneSociale"); if(isset($_GET["orderby"])) { if($_GET["direct"]=='des') $direct = "DESC"; else $direct = "ASC"; $sql.=" ORDER BY ".$columns[$_GET["orderby"]]." ".$direct; } //if this is the first query - get total number of records in the query result if($posStart==0){ $sqlCount = "Select count(*) as cnt from ($sql) as tbl"; $resCount = mysql_query ($sqlCount); $rowCount=mysql_fetch_array($resCount); $totalCount = $rowCount["cnt"]; } //add limits to query to get only rows necessary for the output $sql.= " LIMIT ".$posStart.",".$count; //query database to retrieve necessary block of data $res = mysql_query ($sql); //output data in XML format print("<rows total_count='".$totalCount."' pos='".$posStart."'>"); while($row=mysql_fetch_array($res)) { if($res) { if($row["dataRevisione"]) $data=$row["dataRevisione"]; else $data=$row["dataInserimento"]; print("<row id='".$row['ID']."-".$row['revisione']."'>"); print("<cell>"); print(htmlspecialchars($row["ID"])); print("</cell>"); print("<cell>"); print(htmlspecialchars($row["revisione"])); print("</cell>"); print("<cell>"); print(substr($row["operatore"],0,3)); print("</cell>"); print("<cell>"); print(htmlspecialchars($data)); print("</cell>"); print("<cell>"); print(htmlspecialchars($row["note"])); print("</cell>"); print("<cell>"); print(htmlspecialchars($row["evasioneInterna"])); print("</cell>"); print("<cell>"); print(htmlspecialchars($row["ID_Cliente"])); print("</cell>"); print("<cell>"); print(htmlspecialchars($row["ragioneSociale"])); print("</cell>"); print("<cell>"); print(htmlspecialchars($row["PDF"])); print("</cell>"); print("</row>"); } else { //error occurs echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>"; } } print("</rows>"); ?> ****************************************************************** Thanks in advance!! FiFFiO Answer posted by Support on Sep 14, 2009 10:10 In command you are using dp = new dataProcessor("update_perventivi.php"); but the file is named update_preventivi.php update_perventivi.php update_preventivi.php Answer posted by FiFFiO on Sep 15, 2009 03:39 Wow! It works, thank you very much! |