我做错了什么。 PHP 似乎无法从 $.ajax 捕获 title
和 wrapper
。代码看起来是否正确。我收到的成功消息指示未找到标题的错误。
jQuery 主.html
$.ajax({
type: "POST",
url: "process.php",
data: 'title=test&wrapper=testing',
success: function(msg){
alert( "Data Saved: " + msg );
}
});
PHP 进程.php
<?php
$title = $_REQUEST['title'];
$wrapper = $_REQUEST['wrapper'];
...
?>
最佳答案
数据参数最好是键/值对对象,它更干净,更容易调试:)
$.ajax({
type: "POST",
url: "process.php",
data: {
title: 'test',
wrapper: 'testing'
},
success: function(msg){
alert( "Data Saved: " + msg );
}
});
关于php - jQuery Ajax 发布到 php 没有捕获变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6517445/