| Page 1 of 1 | [ 5 posts ] |
|
Hi Everybody,
I have a quite strange behaviour while using yui2 DataTable. The setup is quite easy: Code: myDataTable = new YAHOO.widget.DataTable("ctd", myColumnDefs, myDataSource); myDataSource looks like that: Code: myDataSource = new YAHOO.util.DataSource("some_php_file_with_some_get_params"); myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; Additionally I use AutoComplete to filter the ajax results. Code: var getTerms = function(query) { if (myDataSource != undefined) { myDataSource.sendRequest('&query=' + query , myDataTable.onDataReturnInitializeTable, myDataTable); } else { // blahblah } }; If no results can be returned frome the php file called over ajax, it returns: Quote: {"ResultSet":{"totalResultsAvailable":0,"totalResultsReturned":0,"firstResultPosition":1,"ResultSetMapUrl":"","Result":[]} My Problem: In IE 6/7/8, if the quoted string is returend, YUI throws MSG_EMPTY, as expected. But FF (2/3) and Chrome (5/6) throw MSG_ERROR. Any Idea? Best regards, lexx |
|
Your quoted JSON has a missing curly bracket at the end but I guess that was an error in copying. The only strange thing in your description is the argument to your DataSource constructor "some_php_file_with_some_get_params" . You don't usually add your get parameters to the URL in the constructor. That is what the initialRequest configuration attribute is for, which goes into the fourth argument of your DataTable constructor, which is missing in your code.
The URL you use for the DataSource constructor is the base URL, that which remains the same all through the transaction. If you include your get parameters in the base URL, your extra arguments in the call to sendRequest will be appended to those, possibly confusing your server. A confused server often responds with a nicely formatted HTML error message instead of the expected JSON reply, and that causes the MSG_ERROR. Another possible cause for error is not escaping the query. You should use: myDataSource.sendRequest('&query=' + encodeURIComponent(query) , ... otherwise, certain queries for example, with a whitespace, will truncate the URL or confuse the server with strange arguments. |
|
Hi Satyam,
thanks for your answer. I can exclude any server error since I see the XHR-Answer with Firebug/Chrome's DevTools. Your're right,the end-bracket is missing in the quote. But as you suspected, it was a copy error, the server returns a correct json string. I fixed the GET-Params and encoded the URI as you suggested. Maybe you have any other idea.. thanks ! PS. This is my AutoComplete: Code: var oACDS = new YAHOO.widget.DS_JSFunction(getTerms); oACDS.queryMatchContains = true; oAutoComp = new YAHOO.widget.AutoComplete(inputel, searchdiv, oACDS, { minQueryLength: 0 }); |
|
We haven't been doing things that way since 2.5.2. Autocomplete uses the same DataSource classes as DataTable does.
What versions are you using? |
|
Hi satyam,
a strange encoding setting of my apache caused some browsers to behave like that. thanks - i solved the problem. |
| Page 1 of 1 | [ 5 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group