在我的应用程序中,我使用ajax发送mails.There,我传递的电话号码是111-111-1111,这可能会也可能不会纠正工作客户端的服务器。这是我的ajax代码
var va = $("#txtname").val();
var va1 = $("#txtphone").val();
$.ajax({
type: "POST",
url: "http://localhost/houndzabout/process.php/"+va+"/"+va1,
success: function(msg) {
if(msg == 0) {
alert("Your Request Is Send!");
} else {
alert("Your Request Is Failed!");
}
}
});
发布于 2011-12-05 15:46:33
使用参数,如;
var request = $.ajax({
url: "http://localhost/houndzabout/process.php",
type: "POST",
data: {name : $("#txtname").val(), phone: $("#txtphone").val()},
success: function(msg){
if(msg == 0)
{
alert("Your Request Is Send!");
} else {
alert("Your Request Is Failed!");
}
}
});
在process.php文件中,获取参数如下;
if(isset($_POST['name']))
{
$name = $_POST['name'];
}
if(isset($_POST['phone']))
{
$phone = $_POST['phone'];
}
发布于 2011-12-05 15:38:25
您的类型为"POST“,但您正在使用GET方法(在url中)传递变量。您需要设置一个数据JSON对象并以这种方式传递数据。
var request = $.ajax({
url: "http://localhost/houndzabout/process.php",
type: "POST",
data: {
va: $("#txtname").val(),
va1: $("#txtphone").val()
},
success: function(msg){
if(msg == 0)
{
alert("Your Request Is Send!");
} else {
alert("Your Request Is Failed!");
}
}
});
https://stackoverflow.com/questions/8382193
复制相似问题