jquery ajax =>未定义索引php [英] jquery ajax => Undefined index php

查看:152
本文介绍了jquery ajax =>未定义索引php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对php有问题.

AJAX

    $(document).ready(function(){

$.ajax({
  type: "POST", // i test post, get...
  url:'TESTING.php', 
  data: {name: "alfred"},
  success: function(){  
      alert("success"); // it show "success" !... :/
    } 
});
});

和php

<?php 
//var_dump($_POST); array is empty
$name = $_POST['name']; // error line
echo $name;
?>

我在Localhost上对其进行了测试(如果有问题).而且我不知道,哪里有错误. 谢谢您的帮助

I test it on Localhost (if it is the problem). And i dont know, where is mistake. Thanks for any help

推荐答案

var weightd = $("#weight").val();
var user_id = <?php echo $current_user->ID; ?>;
$.ajax({
                 type: "POST",
                url:"<?php bloginfo('template_directory')?>/ajax/index.php",
                data: { weight:weightd,user_ids:user_id},
                success:function(result){
                  $("#result1").html(result);
                  setInterval(function() {
                    $('#result1').hide('slow');
                    }, 5000);
                }});


<div id="result1"></div>

尝试以此用户

这篇关于jquery ajax =&gt;未定义索引php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆