ajax calling with wordpress

Hi All

I am developing a prototype for a business idea. I am using wordpress for this. I created many widgets that do the functionality with mysql database.

I learn myself how to program ajax and it looks very appealing and want to integrated with my prototype. Saying that, here is my general question. I do want to write the business logic independent of wordpress but still use the wordpress as a platform in the prototype the website and serve initial customers. So I thought develop the php classes and write the code in it and call through ajax to get the data and display on the workpress page.

Questions are:

Is this a good practice ?

How to get my php files to know if the user actually logged in with proper accounts in to wordpress site before process any data at ajax call.

Is there any limit of writing ajax in client side scripting ?

Than you
Who is Participating?
greetings Peiris, , I'm posting here to try and help, since no one else has, although it's been a while since I have done anything in wordpress.
You ask - "Is this a good practice ?" If you are using your own AJAX javascript , this may not work so well in the "contained" framework of wordpress. There is a wordpress extension that is for browser AJAX setup and use, you may be better off with that, you can see one of them here -
but there are others, if you want to see some of the "Code" methods of wordpress ajax, look at this -
but because there are many different parts or "sections" of wordpress, your code may not "Fit" in to the framework, , as you ask - "to know if the user actually logged in with proper accounts", these are values stored in wordpress data, similar to Session storage in PHP, and you can access them in the wordpress framework, but maybe not so easy outside of that framework.

You ask - "Is there any limit of writing ajax in client side scripting", , well obviously there must be some limit, however the modern browsers can do LARGE amounts of script including ajax calls, however ajax is mostly used as asynchronous calls, and you would probably need some mechanism if you have alot of ajax data retrieval, that checks to see if one request is finished before another is started, but this is dependent on code interactions. I do not think there is a simple answer to this "limit" thing, but I can not see this as a problem, unless function code is bumping into each other due to asynchronous calls.

As I said you might should try and use an ajax plugin, because it will already be in the framework.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.