title: Escaping Double quotes Using jquery
body: <p>I Have scanerio where user searches  for text using search box.SO my search criteria whenever user eneters word  we have to search first All matching criteria then next least matching criteria and at last single matching criteria. For example if user searches "Device Transaction failed". Then we have to show three words matching criteria first then  next any two of them at last single.I have server side programming.But here has one scenario when user enters in double quotes then it has to be taken into single word and then search  on server side. i have written ajax call shown below</p>
  
  <pre><code>$('.search').bind("keyup change",function() {
                var category=$("#category").val();
                  var search=$("#filter").val();
                   var array = search.match(/"[^"]*"|[^\s"]+/g);
                 console.log("hi"+array.length);
                 for(var i=0;i&lt;array .length;i++)
                 {
                 array[i]=JSON.stringify(array [i].replace(/['"]+/g, ''));
                             }
  
                 console.log(array);
                 $.ajax({
        url: '/portalmanager/search.ajax',
        type: 'POST',
        data: {searchText:array.join(","),category:category},
        cache: false,
        dataType:'text',
        success: function(data)
        {
         $("#xyz").html(data);
        }
       });
   });
  </code></pre>
  
  <p>But when i am sending double quotes in slashes javascript object is not sending correctly as i expected .I have tried  to escape quotes and replace quotes with slash quotes.All these failed as it is sending string as multiple words if i entered in dobule quotes also.
  When i use JSON.stringify it is sending as expected.Can i use JSON.stringifyon individual array element?If not can anyone suggest me better way of doing that.</p>
  
  <p>Suppose for if user enters in search box as "what is the bi" opc then it should be sent as
   "\"what is the bi\"  " ooc  to the server side.</p>