ajax calling with wordpress

Posted on 2012-08-22
Last Modified: 2012-08-31
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
Question by:Peiris
    1 Comment
    LVL 33

    Accepted Solution

    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.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    In Part I (, I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to count occurrences of each item in an array.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now