ajax 没有传值,Jquery ajax数据值没有传递给目标url

我遇到了一个错误我的id值没有传递给脚本你能帮我吗?这可能是由于数据造成的:从窗体获取所有数据并以某种方式覆盖ID号码?Jquery ajax数据值没有传递给目标url

var otherPro = $('.euserId').text();

console.log(otherPro);

$.ajax({

type: "POST",

url: "modifyuser.php?id=" + otherPro,

data: $('form.editUser').serialize(),

beforeSend: function() {},

success: function (msg) {

$("#msgholder1").html(msg)

console.log(msg);

},

error: function() {

$("#msgholder1").html("error")

}

});

调试

consol.log#1 51 (index):66 - this is the value of "+ otherPro

php response (var_dump($_POST['id']))

Notice: Undefined index: id in C:\xampp\htdocs\platform\admin\modifyuser.php on line 10

consol.log#2 NULL

php response (if no ID given)

Form

No Id Given

php文件

require_once("../checklogin.php");

require_once("../lib/functions.php");

require_once("../lib/Db.class.php");

// Creates the instance || preg_match('/^(?=.*\d)(?=.*[A-Za-z])[[email protected]#$%]{8,12}$/', $_POST['password'])

$db = new Db();

$user = new users();

$error = array();

var_dump($_POST['id']);

if (empty($_POST['id'])) {

$error[] = 'Brak podanego id';

} else {

$username = $_POST['id'];

}

if (empty($error))

{ // If everything's OK...

$teto = $user->Find($_POST['id']);

if(!empty($teto))

{

$update = $db->query("UPDATE Persons SET username = :username, name =:name, surname = :surname, password = :password, lastlogin = :lastlogin, isOnline = :isOnline, level = :level WHERE id = :id", array(

"id" => $_POST['id'],

"username" => $username,

"name" => $name,

"surname" => $surname,

"password" => $password,

"lastlogin" => '0000-00-00 00:00:00',

"isOnline" => '0',

"level" => $level

));

?>

$(".editUser").hide();

$('#editUser').hide();

var result = '

Modyfikowano wpis.

', //html for main result

delay = 200, //delay of sub results

data = Array(

'

Polaczenie z baza green_tick_small.gif',

'

Modyfikacja wpisu green_tick_small.gif'

);

//self executing function starting from array index 0

(function process_els(el_index) {

var el = data[el_index],

precheckUl = $('#precheck ul'),

loadingLi = $('

ajax_loader.gif'),

sysPreId = "syspre_"+el_index;

//show loading image

precheckUl.append(loadingLi.clone().attr("id",sysPreId));

//after simulated delay replace loading image with sub check result

setTimeout(function()

{

precheckUl.find('li.loading:first').replaceWith(data[el_index]);

}, delay);

//to simulate the delay recursively call itself until all array elements have been processed

if (el_index + 1 < data.length) {

setTimeout(function() { process_els(el_index + 1); }, delay);

}

else

{

setTimeout(function()

{

//append the final result after all sub checks have been inserted

precheckUl.after(result);

}, (delay*2));

}

})(0);

Modyfikacja wpisu

}else{

echo "

No ID Error
";

}

} else { //If the "error" array contains error msg , display them.... e.g....

echo '

Bledy w formularzu

';

foreach ($error as $key => $values) {

echo '' . $values . '
';

}

echo '

';

}

+0

添加php脚本和html也 –

+0

你可以通过set type来获得 –

+0

发布var_dump($ _ POST)的结果; –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值