When populating a grid, no problem using FF.
But with IE it takes a very long time, then the message "Sorry, an error occurred"
appears.
How could I get around that?
When populating a grid, no problem using FF.
But with IE it takes a very long time, then the message "Sorry, an error occurred"
appears.
How could I get around that?
Example code please.
Can you post a code snippet?
That's the piece that loads
That's the piece that loads data from a php script (mysql data in json format) and populates the grid.
Works perfect in FF, but not on IE6/7. I even tried from different PCs and different networks/locations.
var u_grid_clients = function () {
store4 = new dojo.data.ItemFileWriteStore({ url: 'get_clients.php' });
dojo.addOnLoad(function(){
var layout4 = [
{ field: 'ID_K', name: 'ID_K', width: '5em',hidden: false },
{ field: 'ID_K_Orig', name: 'ID_K_Orig', width: '5em',hidden: true },
{ field: 'Vorname', name: 'Vorname', width: '5em',editable: false },
{ field: 'Nachname', name: 'Nachname', width: '5em' },
{ field: 'K_Komm', name: 'K_Komm'}
];
var selected = function(inRowIndex){
var usele=this.getItem(inRowIndex);
var u_inRowIndex=inRowIndex;
update_form_kunde(u_inRowIndex,usele);}
var grid4 = new dojox.grid.DataGrid({
id:'gridNode',
query: { ID_K: '*' },
store: store4,
structure: layout4,
rowsPerPage: 10,
onSelected: selected},
document.createElement('div'));
dojo.byId("gridContainer4").appendChild(grid4.domNode);
grid4.startup();
})
}//Ende u_grid_clients
Further analysis: problem is when source is a php script
The problem is populating the datastore:
store4 = new dojo.data.ItemFileWriteStore({ url: 'get_clients.php' });
when I use the php script, it doenst work.
When I store the result of get_clients.php in a text file, and call it get_clients.json and put
store4 = new dojo.data.ItemFileWriteStore({ url: 'get_clients.json' });
then no problem.
The json looks like (this is just an example, the field names do not match):
{'items':[{"ID_P":"867","UID_O":"867","UNachname":"Holz"},{"ID_P":"896","UID_O":"891","UNachname":"Bader"},{"ID_P":"904","UID_O":"895","UNachname":"Hache"},{"ID_P":"907","UID_O":"898","UNachname":"Schuberth"},{"ID_P":"908","UID_O":"899","UNachname":"Frese"},{"ID_P":"909","UID_O":"900","UNachname":"M\u00fcller"},{"ID_P":"910","UID_O":"900","UNachname":"M\u00fcller"}]}
Are there any script errors
Are there any script errors in IE that shows up?
no, actually not, only the
no, actually not,
only the message "an error ocurred" inside of the grid
Urgent help please, no php scripts can populate datastores!
This is getting really urgent, when using IE, datastores cannot be populated with php!
Any idea around?
I took your test json data
I took your test json data that you posted above, copied it to output from a php script using "echo", created an ItemFileReadStore and had it get that data from a url, loaded a grid with the store and it was fine in IE7.
Is there something different about the way that you're returning the JSON or is the actual data different than what you posted above?
var layout = [
{field:'UID_O',width:'75px', name:'UID'},
{field:'UNachname', width:'480px',name:'Name'}
];
// grid declaration
var store = new dojo.data.ItemFileReadStore({url:'json.php'});
grid = new dojox.grid.DataGrid({
store: store,
structure:layout,
region: 'center'
});
dijit.byId('borderContainer').addChild(grid);
grid.startup();
Here is the code for my php script:
thanks a lot, that proves
thanks a lot, that proves that my guess was wrong!
I further investigated my code.
It has to do when exactly what is loaded when loading my quite big php page (including html parts and everything).
I use
dojo.addOnLoad(function() { myinit(); });
and in myinit(), there is quite some code.
When I removed part of my html page, it suddenly worked (in FF I never noticed a problem).
I will have to do some research what exactly could that be,
but in any case, there are some nested divs including dojo buttons which did NOT pick up the dojo colors,
whereas others YES where correct dojo buttons. So when these were loaded, there somehow was no dojo loaded yet...
any idea?
Make sure all html elements
Make sure all html elements are open/ended. Are you using Firebug with FF? And if so, are there any errors? You can also try to drill down where the exact issue arises by putting the HTML you deleted back in a small bit a at a time while testing each time.
Well, the html topic, was an
Well, the html topic, was an issue, but it was something different.
The php problem is still around. When populating with a pure "echo", it works,
but when retrieving from an MySql database, it doesnt:
CASE ECHO
--------------------
I use a php script very similar like yours:
echo '{"items":[{"ID_K":"799","ID_K_Orig":null,"Vorname":"Helga","Nachname":"G\u00f6rgen","Firma":"","Strasse":"Mittelstr. 31","Land":"D","PLZ":"51379","Stadt":"Leverkusen","Email":"Peterop@t-online.de","Telefon":"","Ebay_Name":"Online Shop","K_Komm":""},{"ID_K":"798","ID_K_Orig":null,"Vorname":"Dieter","Nachname":"Luengen","Firma":"","Strasse":"Am Osterholz 95","Land":"D","PLZ":"42327","Stadt":"","Email":"dieter.luengen@freenet.de","Telefon":"","Ebay_Name":"anne-marie.0202","K_Komm":""}]}';
that produces of course:
{"items":[{"ID_K":"799","ID_K_Orig":null,"Vorname":"Helga","Nachname":"G\u00f6rgen","Firma":"","Strasse":"Mittelstr. 31","Land":"D","PLZ":"51379","Stadt":"Leverkusen","Email":"Peterop@t-online.de","Telefon":"","Ebay_Name":"Online Shop","K_Komm":""},{"ID_K":"798","ID_K_Orig":null,"Vorname":"Dieter","Nachname":"Luengen","Firma":"","Strasse":"Am Osterholz 95","Land":"D","PLZ":"42327","Stadt":"","Email":"dieter.luengen@freenet.de","Telefon":"","Ebay_Name":"anne-marie.0202","K_Komm":""}]}
CASE MySql
--------------------
When getting the data out of mysql, my code is:
<?php
header('Content-Type: text/html; charset=utf8');
include 'rc_config/datalogin.php';
$res=mysql_query("Select ID_K,ID_K_Orig,Vorname,Nachname,Firma,Strasse,Land,PLZ,
Stadt,Email,Telefon,Ebay_Name,K_Komm from clients order by ID_K DESC limit 2");
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
$ares[]=array('ID_K'=>$row['ID_K'],'ID_K_Orig'=>$row['ID_K_Orig'],'Vorname'=>$row['Vorname'],
'Nachname'=>$row['Nachname'],'Firma'=>$row['Firma'],'Strasse'=>$row['Strasse'],
'Land'=>$row['Land'],'PLZ'=>$row['PLZ'],'Stadt'=>$row['Stadt'],'Email'=>$row['Email'],
'Telefon'=>$row['Telefon'],'Ebay_Name'=>$row['Ebay_Name'],'K_Komm'=>$row['K_Komm']
);
}
$aresj=json_encode($ares);
//echo "{'items':";
echo '{"items":';
echo $aresj;
echo "}";
mysql_close();
?>
That produces EXACTLY the same output:
{"items":[{"ID_K":"799","ID_K_Orig":null,"Vorname":"Helga","Nachname":"G\u00f6rgen","Firma":"","Strasse":"Mittelstr. 31","Land":"D","PLZ":"51379","Stadt":"Leverkusen","Email":"Peterop@t-online.de","Telefon":"","Ebay_Name":"Online Shop","K_Komm":""},{"ID_K":"798","ID_K_Orig":null,"Vorname":"Dieter","Nachname":"Luengen","Firma":"","Strasse":"Am Osterholz 95","Land":"D","PLZ":"42327","Stadt":"","Email":"dieter.luengen@freenet.de","Telefon":"","Ebay_Name":"anne-marie.0202","K_Komm":""}]}
But when loading into the datastore, the version reading from MySql is NOT working!
That looks like timeout or whatever, even though I limited the output to only 2 records.....
How long does the request
How long does the request take to get the data back from the php script? Firebug shows the time it takes to return in FF.
I measured like this: var
I measured like this:
var timeName = 'measuringTime';
console.time(timeName);
store4 = new dojo.data.ItemFileWriteStore({ url: 'test_php.php' });
console.timeEnd(timeName);
In case of the "pure echo" script, it says "0ms",
in case of the mySql load, it says "1ms".
Any further idea?
I also measured the loading
I also measured the loading itself,
in this case it is 78ms with the pure echo, and in the other case, the grid is not filled, it eternally
says "loading" but never loads, but giving 94ms as the measure time.
dojo.addOnLoad(function(){
var timeName2 = 'measuringTime2';
console.time(timeName2);
var layout4 = [
{ field: 'ID_K', name: 'ID_K', width: '5em',hidden: false},
{ field: 'ID_K_Orig', name: 'ID_K_Orig', width: '5em',hidden: true },
{ field: 'Nachname', name: 'Nachname', width: '10em' ,cellStyles:'color: red;'},
{ field: 'Vorname', name: 'Vorname', width: '8em'},
{ field: 'Firma', name: 'Firma', width: '3em',hidden: true },
{ field: 'Strasse', name: 'Strasse', width: '12em'},
{ field: 'Land', name: 'Land',hidden: true },
{ field: 'PLZ', name: 'PLZ',width: '5em' },
{ field: 'Stadt', name: 'Stadt',width: '12em'},
{ field: 'Email', name: 'Email',width: '4em',hidden: true },
{ field: 'Telefon', name: 'Telefon',width: '2em',hidden: true },
{ field: 'Ebay_Name', name: 'Ebay_Name',width: '8em',hidden: true },
{ field: 'K_Komm', name: 'K_Komm',hidden: true }
];
var selected = function(inRowIndex){
var usele=this.getItem(inRowIndex);
var u_inRowIndex=inRowIndex;
update_form_kunde(u_inRowIndex,usele);}
eval("var grid4 = new dojox.grid.DataGrid({id:'gridNode',query: {"+que+" },store: store4,structure: layout4,rowsPerPage: 10,onSelected: selected}, document.createElement('div'))");
dojo.byId("gridContainer4").appendChild(grid4.domNode);
grid4.startup();
console.timeEnd(timeName2);
})
Loading IE
Has anyone an idea on how to solve that?
Any help is more than welcome!!
hmmm
That's a lot of info. Can you summarize where it's at right now? It works when you echo but not when you send data that you got from MySQL, right? When it doesn't work, what exactly do you see? Is there are URL where I can see both sets of JSON?
Clearly this can only be a couple of things --- either the JSON isn't really the same between the two cases, or else it's not being sent in the same way (perhaps one way is sending application/json and the other is sending text/html or something like that). I think you should use Firebug, pull up the Net tab and expand the line that pulls the JSON so you can check out the headers & the content, then look very closely at both of your cases to see if there are differences. Maybe there's some "hidden" character in the JSON that's coming from Mysql, encoding or something, just brainstorming.
What's up with the \u in the data? Have you tried using a data sample with no embedded backslashes? I'd try that, just to be safe.
So you're putting "items:" in there. Hmm, doesn't ItemFileRead/WriteStore require the Identity attribute? Maybe I'm misremembering ... I'll go look it up.
Dylan Tynan
Your JSON is missing the Identifier: attribute
claudio, it looks like maybe your JSON is missing the Identifier: attribute. If so, I'm surprised it works at all, but perhaps that's the issue. If you look at the JSON that fivefeet posted, above, you'll note that aside from "items:" there is also "identifier:" at the top-level of the JSON. I don't see that in the JSON you posted, nor in the PHP code that you're using to put items: in there. That could be a problem, though I don't know if it's the problem you're seeing...
Dylan Tynan
Summary
Important: When using FF, no problem.
When using IE7 (and also IE8 or IE6), the problem is to populate a ItemFileReadStore using php.
When populating with php, simply "echoing" the output the initial php script (with mySql), also no problem.
The code in dojo/javascript is identical, only the php script is replaced (either echo a string or echoing the result of a select).
I also thought about the identifier attribute. When I include it, then it doesn't work at all, also not in FF.
So, when using php reading mySql, then in IE the GRID appears, but it says "Error when loading data" or a similar message
when using a german version of IE, in any case the message is inside of the grid.
How to deeper look into with Firebug I did not quite understand....
thanks for your help!
claudio
that's tough
Sorry I was thinking Firebug would help, but it's working on FF, not IE, ok, I understand. Have you ever used Fiddler? It's easy to setup & use, but takes a couple of minutes of playing with it to see where the data goes. I think you might try that. It basically just acts as a local proxy server. Install it, run it, from Fiddler I think there's a way to start IE (or maybe you just start it yourself), then browse using IE and you'll see all the traffic appear in the Fiddler panels. You can look around through there very closely at your JSON and at the HTTP headers being sent and see if you see anything strange. Actually, what you want to do, is run it once using the echo method, and again using the mysql method & closely compare the two sets of HTTP headers and JSON --- there must be some difference ... I guess there's the very unlikely possibility it could be at the socket/network level, but, again, seems unlikely.
Let us know. Actually, if you can, copy out the exact set of headers & JSON for the echo test and put that in a file. Then, do the same for the mysql test. Then diff those two ... you'll see some differences due to dates/times, etc. but maybe that will help identify the issue.
Dylan Tynan
Comment this out of your
Comment this out of your mysql version test. When I included this header into my previous Json.php file, it got the exact error message in the grid when loading with IE. In Firefox, it was fine. When I comment the header out, it's fine in both browsers.
----------------------------------------------------------------------------------------
Health/Beauty/Food/Computers/Travel
SimplyBuyIt - Everything
YOU ARE GREAT
Thank you so much! Removing the header solved the issue!
Now I'll have to go in depth of that, trying special utf8 characters etc., but in principle, it works.
I am mainly using IE8, so for dojo 1.3 it would be good to check that issue and solve it.
That's good news...
Out of curiousity, was it that two Content-type headers were being sent, or was it the charset-utf8 encoding portion on the header was the issue? I wasn't entirely clear on that ...
Dylan Tynan
Looks like it was the
Looks like it was the charset-utf8. If I modify the header to exclude it, IE7 loads the data fine with the header.
----------------------------------------------------------------------------------------
Health/Beauty/Food/Computers/Travel
SimplyBuyIt - Everything
yes, it was the charset-utf8
yes, it was the charset-utf8 portion,
but I don't understand why IE doesnt want it.
When I sent only the echo in the php, there was no utf8 being set.
It's still weird, as the output from php was really identical.
Interestingly it also loads
It also loads fine in IE7 with the charset defined as "utf-8".
Which leads me to believe that was the crux of your issues. I did a search for charset "utf8" and most defined it as "utf-8".
http://www.utf-8.com/
Also, even with the charset set to "utf8", the page info FireFox dialog still displays "utf-8" while the reponse headers it gets from the php file is "utf8". Maybe Firefox realizes it's utf-8 and uses accordingly while IE simply doesn't.
----------------------------------------------------------------------------------------
Health/Beauty/Food/Computers/Travel
SimplyBuyIt - Everything