How can I $_POST information to this page without going to it by submitting a form?
I'开发者_开发问答m using the following code:
$.ajax({
type:'GET',
url: 'save_desc.php?scrapbook_name=<?php print(addslashes($scrapbook_name)); ?>,
success: function(data){
$("#" + id + "below").html(data);
}
});
How can I change this to sending sensitive information (with "special" characters) by posting it rather than using the $_GET method?
NOTE: I've tried to use addslashes
but this doesn't have any affect in passing strings with wildcard characters.
Change the type
parameter to 'POST', or alternatively use jQuery's post()
function:
$.post(
'save_desc.php',
{ scrapbook_name: <?php print(addslashes($scrapbook_name)) },
function(data) {
$("#" + id + "below").html(data);
}
);
http://api.jquery.com/jQuery.post/
On top of the post comment from RoccoC5, you can use the jquery serialize function into a variable then use the variable in the post
var PostData = $(myform).serialize();
$.post("myphppage.php",
PostData,
function()
{
//completion code goes here
},
"html")
.error(alert("error with post"));
http://api.jquery.com/serialize/
http://api.jquery.com/jQuery.post/
精彩评论