PHP library for jQuery

    jQuery-PHP

    Since the combination of "Web 2.0" came to the masses, more and more site developers have to add "web 2.0 prettiness" to sites. The jQuery JavaScript framework really helps with this. Describe all the charm of this framework, I think it makes no sense (it is already too much has been written), but I like PHP developer lacked convenient saithe server to generate AJAX responses, eventually came to light PHP library is the jQuery-PHP ...


    What's this special library? Well, first of all, this is the syntax - it is very similar to the JavaScript part, here is an example for you:

    $ ('# test0'). html ('new content');


    The PHP code for generating such a script is as follows:

    jQuery :: jQuery ('# test0') -> html ('new content');


    As you can see from the example, the syntax really repeats the familiar jQuery for many. This is of course a simple little example, let's try a harder thread:

    jQuery :: jQuery ('# test3 div') -> bind ('click', array ('test' => 'answer'), 'eventAlert')
    -> css ('cursor', 'pointer')
    -> css ('color', '# 0000ff')
    -> css ('textDecoration', 'underline');


    or even so:

    jQuery :: jQuery ('# test2 div') -> html (date ('H: i: s').': new content ')
    -> css (' backgroundColor ',' # 0000ff ')
    -> filter (' .red ')
    -> css (' backgroundColor ',' # ff0000 ')
    -> filter (' filter ')
    -> css (' backgroundColor ',' # 00ff00 ');


    As you can see, even such relatively complex chains work.

    At the moment, I could not test the operation of all functions, I know for sure that the following nuances exist:
    • jQuery methods to which callback functions can be passed as parameters can be called in PHP, but javascript functions cannot be generated on the fly, therefore the name of an existing function should be used as parameters
    • to support callback functions, you have to write exclusion rules in the jquery.php.js file (see the megaswitch starting at line 30)
    • not tested at all with plugins


    Also in this library there are utility methods:
    • addMessage - add message
    • addError - add error message
    • evalScript - execute javascript


    PS It will not be entirely honest. if I say that I wrote this library myself, two people helped me in writing it: josser and B_Uhuru (more precisely, they started, but I took the hammer and chisel and redid everything again) ...

    updated : this library is very similar in purpose to Xajax , only the client side uses jQuery and a small class to parse the server response.

    Also popular now: