the Searching in ajax does not return result with spaces

After clicking the search button in my page it typically outputs the result of the query. however i have a problem with regards to conditions where the value of the field has a white space. so what i am doing is to trim the string and look it up in the database using LIKE statement.
$(document).ready(function(){ 
 $('#btnsearch').click(function(e) { 
        $("#content0 #sub_cont0").load("view/search.php?document=<?php echo $_GET['document']; ?>&stat=<?php echo $_GET['stat']?>&ac=<?php echo $_GET['ac']; ?>&fac=<?php echo $_GET['fac']; ?>&val=" + $("#txtsearch").val() + "&model=<?php echo trim($_GET['model']);?>"); 
        $(".tblmodellist").fadeOut("slow"); 
  }); 
});


example i will search for the word "casing". under the category model = "Test Model". When this is queried in the database, it does not output anything using this query. NOTE: in the above script, I trimmed the model so the output will be "Test" only. But still it does not return my expected result set.
  1. <?php  
  2.   $sql =    "SELECT * FROM $db WHERE ( 
  3.     FileName LIKE '%" $id "%' OR 
  4.     $title LIKE '%" $id "%' OR 
  5.     $no LIKE '%" $id "%' ) 
  6.     AND (Stat = '$stat' AND Model LIKE '%".$model."%') 
  7.     "

    What do you think is the problem in my ajax request? I have found earlier during my debug that when I put the $_GET['model'] in the center, it cuts down the query resulting in a NULL value, that is the reason why i put it in the end of the line.
    PHP MYSQL AJAX

    Submitted by hakam On Tuesday, 20 August 2013.
    Category: MySql

    [RESOLVED]

    1
    1 Answers.
     
    Super User
    crooker

    Re:the Searching in ajax does not return result with spaces

    use following code
    1. <?php  
    2. $model urldecode($_GET['model']); 
      Submitted by Super User On Tuesday, 20 August 2013
      0
      This Answer has been Chosen as Best Answer
      Question is marked as resolved.