tightorbit on "What must I expect getting into, by "ajaxifying" my plugin?"

ساخت وبلاگ

Maybe some of you from the community could help me get past a dilemma I have over using AJAX in WP, which I have not done before.

I am in the early stages of building a WP plugin for enabling a logged-in user of a WP site or blog to submit a short, simple form. For the sake of argument, values entered in the form will be the principal, the interest and monthly installment on the repayment of a bond.

The idea here is to allow the user to inquire how long it will take (i.e. the number of installments) until the bond is paid off, depending on how big or small an installment she pays . This will be displayed as a response in a text area or box at the bottom of the form.

Using this form she could then explore various scenarios by re-entering different installment amounts and re-submitting the form on each such change.

If I were to build such a plugin in a simple, no-frills way, then each time the user will re-submit this form that will cause a re-load of the page or post in which it lives. Moreover, because of its small size, this plugged-in form will likely share room on a page or post with other content.

So the conventional wisdom here would argue for me to add some Javascript and "ajaxify" my form, in order to reduce page reloading by refreshing the content of only the "number-of-remaining-installments" box with the result to be fetched by AJAX from the server. In theory this sounds good.

But I have gathered from various sources that Admin-ajax.php can carry with it its own overheads. That being said and considering that the form with its supporting process will be relatively quite small / simple, would it not be over-kill for me to "ajaxify" my plugin?

It is not as if there were dozens and dozens of different input values of the form which would need undergo repeated validations on a server to warrant the added complexity, that would come with Ajax in the mix.

The counter view is of course, that if there were to be many different subscribers all using this plugin simultaneously, this could add significantly to the volume of traffic with the server.

By the way, there would actually be more PHP work going on in the back-end than what I have indicated in my over-simplified example, which is why I would prefer avoid doing the calculation in the front-end with Javascript.

As I am undecided due to my confusion over this issue of the trade-offs, I would really appreciate hearing your views and feedback on this.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 237 تاريخ : يکشنبه 23 خرداد 1395 ساعت: 2:58