jQWidgets Forums
jQuery UI Widgets › Forums › Plugins › Data Adapter › dataAdapter is not loading the data
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 9 years, 6 months ago.
-
Author
-
Hi Team,
Recently I have upgraded my jQWidget version to v3.9.1, I’m facing few issues in the existing functionalities which was working fine with jQWidget version v3.2.2.
I am using the jqx.dataAdapter to load JSON data. See below my implementation. While running the code, data is not loading. I checked the Apache tomcat log, I’m getting JSONException:Input string is not well formed JSON (invalid char ?)
I did some trial and error, It’s working file when I remove contentType: ‘application/json’ from the data preparation section.
Is it advisable to remove this line of code? I hope contentType is mandatory. Or suggest me to solve this issue.
var accountsurl = "/root/nameList.xhtml"; /*----- Prepare the data ---------*/ source = { datatype: "json", type: 'POST', contentType: 'application/json', datafields: [{ name: "Name" }, { name: "ID"}], root: "nameList", url: accountsurl }; nameListDataAdapter = new $.jqx.dataAdapter(source, { autoBind: true, beforeLoadComplete: function (data) { nameList=[]; nameListSelected = []; var newlength= nameListDataAdapter.records.length; for (var i = 0; i < newlength; i++) { var record = nameListDataAdapter.records[i]; nameList.push(record.personName); } var newnameList=[]; $(nameList).each(function(i, el){ if($.inArray(el, newnameList) === -1) newnameList.push(el); }); nameList = newnameList; uiComponents(); } });
Thanks in advance…
Best Regards,
ShelanHi Shelan,
It that is the error, then the Input string is not well formed JSON because that error is raised by the jQuery’s parseJSON and that is independent on the jQWidgets version.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you very much for your quick response.
Is it advisable to remove
contentType: ‘application/json’
from the data preparation section? Will it give any impact?The same code is working fine if I use the older version(which I was already using in my project), I couldn’t able to understand the problem. Please help me to solve this issue.
Thanks in advance…
Best Regards,
ShelanHi Shelan,
contentType is an optional setting so I do not know whether you app requires it or do not i.e I can’t advice you anything. The error I repeat is caused due to invalid JSON.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.