Reputation: 4504
I have a auto-complete form that fetches result from server, but on slow connection it becomes erratic as data loading takes time. Is there anyway we can prefetch data from ajax source
Upvotes: 0
Views: 1506
Reputation: 9154
Just to answer your question, prefetch is possible using synchronous AJAX. Using jQuery, it will be (check syntax since I am on phone).
$.ajax({
url: "",
async: false,
success: function(resp)
{}
});
This will make sure that your data is loaded before you publish it. But as Sinethera said, this defeats entire purpose of AJAX. If you can pre-fetch the content, that means you know the expected content. Then why not put it as a static list?
Upvotes: 1
Reputation: 9429
Prefetch? Isn't that called "not being ajax"? Just load the data with the page and use it as a static data source.
Optionally get the data when they "focus" the field. That would be the only real compromise between getting the data on page-load and doing a legitimate dynamic source.
Upvotes: 1