由网友(专属、我的devil ▓)分享简介:$.ajax({method: "post", url: "save.php", data: "id=453&action=test" , beforeSend: function(){} , complete: function(){ } , success: function(html){ $("#mydiv")...
$.ajax({
method: "post"
, url: "save.php"
, data: "id=453&action=test"
, beforeSend: function(){
}
, complete: function(){
}
, success: function(html){
$("#mydiv").append(html);
}
});
我已经设置方法类型后,但在Save.php我只是得到要么但不是在$ _GET或$ _REQUEST $ _ POST值。
I have set method type as post but in Save.php I just get values either in $_GET or $_REQUEST but not in $_POST.
我的表看起来像
<form method="post" id="myform" action="save.php">
这是行不通的,看了看周围,并在这里对谷歌,试图加入加密类型
It was not working, looked around here and on Google, tried adding enctype
<form method="post" id="myform" action="save.php" enctype="application/x-www-form-urlencoded">
但还是$ _ POST空?
but still $_POST empty?
我如何使它工作?谢谢你。
How do I make it working? Thanks.
推荐答案
而不是方法:文章
则需要使用键入: POST
所以这应该没有任何改动你的HTML表单:
So this should work without any alterations to your form HTML:
$.ajax({
type: "POST"
, url: "save.php"
, data: "id=453&action=test"
, beforeSend: function(){
}
, complete: function(){
}
, success: function(html){
$("#mydiv").append(html);
}
});
不知道为什么它不工作,但这个工作对我来说:
Not sure why it doesn't work but this works for me:
save.php
<?php
print_r($_POST);
file.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('input').click(function() {
$.ajax({
type: "POST"
, url: "save.php"
, data: "id=453&action=test"
, beforeSend: function(){
}
, complete: function(){
}
, success: function(html){
alert(html);
}
});
});
});
</script>
</head>
<body>
<div id="main"><input type="button" value="Click me"></div>
</body>
</html>
您错误必须位于其他地方。
Your error must lie somewhere else.
相关推荐
最新文章