title: Javascript variable into postdata of jqGrid
body: <p>Right now I have this <code>postData: { search: function() { return $("#search").val(); },},</code></p>
  
  <p>I then have jQuery function above the jqGrid function that performs some logic and produces a string variable. Right now I am just taking that variable and setting the value of the search element like this:</p>
  
  <pre><code>$("#startSearch").click(function() {
  
    $("#search").val(searchVal);
  
     $("#grid").trigger("reloadGrid");
  
  });
  </code></pre>
  
  <p>This works but I was hopping to do this differently. I want to just pass the seachVal variable that my jQuery function produces right into the postdata. </p>
  
  <p>I tried it like this but its not working postData: <code>{ search: function() { return searchVal; },},</code></p>
  
  <p>I'm getting an error that says searchVal is not defined. I made sure that the searchVal variable is global but it is still not working.</p>
  
  <p>Is this possible or am I just looking at this wrong?</p>
  
  <p>Any help would be great.</p>
  
  <p>Thanks</p>
  
  <p>UPDATE:</p>
  
  <p>Here is a stripped down version of the page:</p>
  
  <pre><code>&lt;fieldset&gt;
  &lt;input type='text' id='search' /&gt;
  &lt;button type='button' id='startSearch'&gt;Search&lt;/button&gt;
  &lt;/fieldset&gt;
  
  
  &lt;script type="text/javascript"&gt;
  
      $(function(){
  
              $("#startSearch").click(function() {
  
                  serchVal = 'transID &gt; "5"';
  
                  $("#search").val(serchVal);
  
                  $("#grid").trigger("reloadGrid");
  
  
              });
  
  
        $("#list").jqGrid({
  
          url:'data.cfc?method=gridData',
          datatype: 'json',
          mtype: 'POST',
  
          jsonReader : {
           root: "rows",
           page: "currentpage",
           total: "totalpages",
           records: "totalrecords",
           repeatitems: false,
           id: "0",
         },
  
        postData: { search: function() { return $("#search").val(); },},      
  
          colModel :[ 
            {name:'transid', label:'Trans ID', width:60}, 
            {name:'companyname', label:'Company Name', width:245},
            {name:'companycode', label:'Company Code', width:245},
            {name:'datasource', label:'Datasource', width:245}
  
          ],
          pager: '#pager',
          rowList:[10,50,100],
          rowNum:'10',
          height:221,
          sortname: 'transid',
          sortorder: 'asc',
          viewrecords: true,
          gridview: true,
          caption: 'Get Trans',
          altRows: false,
          autowidth: true,
          forceFit: true,
          rownumbers: true,
          scroll: false,
          sortable: true
  
        });       
  
        $("#list").jqGrid('navGrid','#pager',{edit:false,add:false,del:false,search:false,view:true}); 
  
      }); 
  
  &lt;/script&gt;
  
      &lt;table id="grid"&gt;&lt;/table&gt;
      &lt;div id="pager"&gt;&lt;/div&gt;
  </code></pre>