2011-08-23 57 views
0

我使用下面的代码:

$.ajax({ 
    type:'GET', 
    url: 'save_desc.php?scrapbook_name=<?php print(addslashes($scrapbook_name)); ?>, 
    success: function(data){ 
    $("#" + id + "below").html(data); 
    } 
}); 

我怎样才能改变这种由发布它,而不是使用$ _GET方法发送敏感信息(用“特”字)?

注意:我试过使用addslashes,但这对传递带有通配符的字符串没有任何影响。

+0

不要使用和addslashes,用'json_encode()'。 addslashes用于数据库工作,而不是javascript生成。 –

回答

3

更改type参数为 'POST',或者使用jQuery的post()功能:

$.post(
    'save_desc.php', 
    { scrapbook_name: <?php print(addslashes($scrapbook_name)) }, 
    function(data) { 
     $("#" + id + "below").html(data); 
    } 
); 

http://api.jquery.com/jQuery.post/

相关问题