View Single Post
Old 12-11-2012, 12:38 AM   PM User | #6
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,549
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ummm...AJAX doesn't do any filtering unless you write it. For that matter, neither does jQuery.

More than likely, you *SHOULD* do the filtering in PHP/MySQL.

Why not something simple:
Code:
$a = isset($_POST["a") ) ? $_POST["a"] : '%'; 
$b = isset($_POST["b") ) ? $_POST["b"] : '%';
??

Usually, people send AJAX requests as part of the query string, though, so then you would use:
Code:
$a = isset($_GET["a") ) ? $_GET["a"] : '%'; 
$b = isset($_GET["b") ) ? $_GET["b"] : '%';
You see it? If there's no a=value in the querystring (or in the post data, as the case may be), then $a defaults to %. If there is a value, $a receives it, same with $b.

It's probably a TINY bit more efficient to code those as
Code:
$a = $_GET["a"]; if ( ! isset($a) ) { $a = "%"; }
$b = $_GET["b"]; if ( ! isset($b) ) { $b = "%"; }
(or use POST instead of GET, of course).
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote