撇号标记在javascript字符串中与Backslash一起发送,该字符串使用ajax作为json对象的一部分发送到p


apostrophe mark is sent with Backslash in javascript string which is being sent to php page using ajax as part of json object

撇号标记在JavaScript字符串中与Backslash一起发送,该字符串使用ajax作为json对象的一部分发送到php页面

var qry="SELECT 
invpurchaseitme.Code, 
invpurchaseitme.Description, 
invunits.Description,
    invpurchaseitme.StoreGroup 
FROM 
    invpurchaseitme 
LEFT JOIN 
invunits 
 ON 
    (invpurchaseitme.UOMCode = invunits.Code)
 WHERE (
   invpurchaseitme.Code LIKE '%d@t@%' 
    OR 
   invpurchaseitme.Description LIKE '%d@t@%' 
    OR 
   invunits.Description LIKE '%d@t@%' 
    OR 
    invpurchaseitme.StoreGroup LIKE '%d@t@%'
) 
    AND 
invpurchaseitme.StoreGroup='"+$("#StoreCode").val()+"' 
ORDER BY invpurchaseitme.Code ASC 
 LIMIT 70"

在使用ajax将d@t@字符发送到php页面后,我将使用explode()在php页面中将其替换为php变量。但我在最后的查询中得到的是''%variablename%''而不是'%variablename%'。我尝试过使用slashes来转义',但结果是一样的。如何在没有slashes 的情况下获取字符串

这解决了我的问题。stripslashes(str)

http://us1.php.net/stripslashes