In my form I have a text field that has data such as >2012-01-01 <2012-02-01
but when I serialize the form and post the data the field only has the >2012-01-01 and not the <2012-02-01.
Where did it go?
$("#grouppositionsform").live("submit",function(e){
e.preventDefault();
$('body').addClass('wait');
$.post("/page.php",$(this).serialize(), function(data){
$('.showdirectory').fadeOut('slow', function() {
$(".showdirectory").html(data);
$(".showdirectory").fadeIn("slow");
});
}).error(function() {
//alert("error");
}).complete(function() {
//alert("complete");
$('body').removeClass('wait');
});
});
The answer is that joomla took that character and said no to it and didn’t parse it.
So the jquery was fine and was posting the data but joomla has a function that makes sure returned data is safe.
So when I checked $_POST[“searchstring”]; all the data was there.
When I use JRequest::getVar(“searchstring”,-1); it protects me and removes the <.
As it happens Joomla explain this here: http://docs.joomla.org/Secure_coding_guidelines
and I changed getVar to allow the data through.
So this worked for me.
$sstr = JRequest::getVar(“searchstring”,’-1′,’REQUEST’,’STRING’,JREQUEST_ALLOWRAW);