开发者

jQuery .get usage. Smart or not?

I have a e-shop page (Prestashop) and I wanted to display some products in home page. My goal is to display 3x newest products, 3x m开发者_开发知识库ost sold products and 3x products from special category.

I have those pages already created.

So I was wondering, if it would be smart to retrieve those products in home page using jQuery .get function?

Of course it would be right to use PHP to retrieve those products, but I don't want to learn this e-commerce ( Prestashop ) functions.


Do these need to be fetched after the page loads via AJAX? Do they change during the user's interaction with the page? Or are they static within the scope of a page load and can they be rendered with the initial page and left as-is?

If they're dynamic, then jQuery AJAX (such as .get()) would be the way to go. You'd need a resource (a "page" of some kind) on the server side to return that data to the jQuery AJAX call, naturally.

If they're fairly static, why not just include that data on the page load in the first place? Using dynamic AJAX functionality is nice and provides a good user experience, but only where it's necessary. There is some additional overhead of making more resource requests to the server, those requests may fail and leave the user with an incomplete UI, etc. Unless it's specifically needed, using dynamic AJAX functionality quickly becomes an over-engineering scenario.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜