为什么这个ajax请求不起作用 [英] Why doesn't this ajax request work
问题描述
我有一个ajax请求,它调用一个将记录插入mysql表的php页面(modit.php)。如果我使用正确的查询运行modadjustments它工作正常并插入三个记录。如果我使用ajax.request从主php页面运行它它不会..任何线索
主要功能
I have an ajax request which calls a php page(modit.php) that inserts a record into a mysql table. If I run modadjustments with the correct query it works fine and inserts three records. If I run it from the main php page using ajax.request it doesnt.. any clues
main function
function modifyThem() {
var formData = jQuery('#modform').serialize();
alert(formData);
// this is = "defid%5B1%5D=5&defid%5B2%5D=6&defid%5B3%5D=8"
new Ajax.Request("modit.php", { method:'post',
data: formData,
async:true,
onSuccess: function(msg) {
jQuery('#edit_them_div').dialog('close');
},
onFailure: function(msg) {
}
});
}
modit.php是
modit.php is
.....
$conn->query($sql="DELETE FROM modified_records where default_id<>''");
if(isset($_GET['defid']))
{
foreach($_GET['defid'] as $did)
{
$conn->query($sql="INSERT INTO modified_records (default_id)
VALUES (:did)", $params=array(':did'=>$did)) ;
}
}
.....
所以如果我跑了
modit.php?defid_1 = 5& defid_2 = 6& defid_3 = 8
这会插入3条记录---成功
但是如果我从主页面尝试相同的话就关闭了div并且什么都没做
我做错了什么
谢谢
我尝试了什么:
尝试将php页面中的$ _get更改为$ _POST,但这不起作用
so if I run
modit.php?defid_1=5&defid_2=6&defid_3=8
This inserts 3 records---SUCCESS
but if I try the same from the main page it just closes the div and has done nothing
What am I doing wrong
Thanks
What I have tried:
Tried altering the $_get in the php page to $_POST but that doesn't work
推荐答案
conn-> query(
conn->query(
sql = DELETE FROM modified_records其中default_id<>'');
if(isset(
sql="DELETE FROM modified_records where default_id<>''"); if(isset(
_GET [' defid']))
{
foreach(
_GET['defid'])) { foreach(
这篇关于为什么这个ajax请求不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!