我究竟做错了什么。 PHP似乎没有从$ .ajax中捕获titlewrapper。代码看起来正确吗?我收到的成功消息指示找不到标题的错误。

jQuery main.html

$.ajax({
   type: "POST",
   url: "process.php",
   data: 'title=test&wrapper=testing',
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
});


PHP process.php

<?php
$title = $_REQUEST['title'];
$wrapper = $_REQUEST['wrapper'];
...
?>

最佳答案

看一下:jQuery.ajax()

数据参数最好是键/值对对象,它更干净,更容易调试:)

$.ajax({
   type: "POST",
   url: "process.php",
   data: {
     title: 'test',
     wrapper: 'testing'
     },
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
});

10-05 20:15
查看更多