Is it safe to manually get JSON via Ajax, save it in JS variable, and then use it as data source?
Is it safe to manually get JSON via Ajax, save it in JS variable, and then use it as data source?
Huk256
Posts: 8Questions: 2Answers: 0
Assuming we have datatable called "oTable", then basically, what I mean is:
- Create some js variable - lets call it "datatableSource";
- Call Ajax, get data from server, and store it inside that variable.
- Then call:
oTable.fnAddData(datatableSource);
- And after we change some data, we call:
oTable.fnClearTable();
oTable.fnAddData(datatableSource);
to repopulate the table...
Question is - is something like this safe, compatible with all browsers? Won't it blow up, when server returns too much data?
Thanks in advance for the answer.
Best regards.
This discussion has been closed.
Answers
Hi,
Absolutely this will work and it can have a number of advantages in some situations - preprocessing the data for example.
Obviously the more data you add to the table, the longer the browsers need to process it - IE6 won't handle the addition of a million rows very well for example!
I would suggest you make sure you have the
deferRender
option enabled, since it reduces the initial strain on the browser when you give it new data.I would also suggest using the new API for 1.10, rather than the old
fn*
methods. Specificallyclear()
androws.add()
here.Allan
Hi,
Absolutely this will work and it can have a number of advantages in some situations - preprocessing the data for example.
Obviously the more data you add to the table, the longer the browsers need to process it - IE6 won't handle the addition of a million rows very well for example!
I would suggest you make sure you have the
deferRender
option enabled, since it reduces the initial strain on the browser when you give it new data.I would also suggest using the new API for 1.10, rather than the old
fn*
methods. Specificallyclear()
androws.add()
here.Allan
Thanks for clarification, I was worried that browsers impose some limits for security reasons, but if we're talking about millions of rows, then this is not an issue - my app will newer come close to that ;]
As for using 1.10... well in any new project I certainly will, but from what I saw, some porting would be required to convert project from 1.9.4 to 1.10, and I fear something would break in the process.
Best regards.
1.10 should be fully backwards compatible, minus infinite scrolling and
fnRender
(upgrade notes.Allan
Hmmm, I will look into it then, I was scared off by new method names (or rather by the fact name changed, I think they are much better then before ;] ).
There is a conversion document available if you want to see the changes. But the old properties will still work.
Allan