
Since the combination of “Web 2.0” has come to the masses, more and more often site developers have to add “web 2.0 prettiness” to sites. The jQuery javascript framework helps a lot with this. I think it makes no sense to describe all the charms of this framework (it’s written too much), but I, as a PHP developer, lacked a convenient pollack server to generate AJAX answers, the
jQuery-PHP PHP library came to light ...
What is special about this library? Well, firstly, this is the syntax - it is very similar to the JavaScript part, here's an example:
')
$ ('# 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 for many jQuery. This is of course a simple example, let's try something more complicated:
jQuery :: jQuery ('# test3 div') -> bind ('click', array ('test' => 'answer'), 'eventAlert')
-> css ('cursor', 'pointer')
-> css ('color', '# 0000ff')
-> css ('textDecoration', 'underline');
or even like this:
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 we 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 that can be passed callback functions as parameters in PHP, but javascript functions cannot be generated on the fly, hence 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 on line 30)
- not tested at all with plugins
Also in this library there are utility methods:
- addMessage - add a 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 (or rather, they started, but I took a hammer and a chisel and redid everything again) ...
updated : this library is very similar in purpose to
Xajax , only on the client side jQuery and a small class are used to parse the server's response.