ajax链接json数据类型调用 - php

我想通过ajax将数据发送到其他页面。我已经隔离了问题。这是代码。

谢谢大家的帮助..但没有效果..

更新的代码

有效...

<script>

     $(document).ready(function(){

     $(".edit").click(function(event) {
    event.preventDefault(); //<--- to prevent the default behaviour
    var box = 1233;
    var size=123;
    var itemname=123;
    var potency=123;
    var quantity=12333;

    var dataString ={
                'box' :box,
                'size':size ,
                'itemname':itemname,
                'potency':potency,
                'quantity':quantity
                };


    $.ajax({
            url: "dd.php",
            type: "post",
            data: dataString,

            success: function(data) {
            alert(data); 

            },
            error: function(data) {
            alert(data);
            }
            });

       });
       });

    </script>

所以我点击链接,它导航到dd.php其中

<?php
echo json_encode(array('itemcode'=>$_POST['itemname']));
   echo $_POST['itemname'];

?>

我得到对象对象作为警报。怎么了?请在这里放点光..谢谢你..

参考方案

$(document).ready(function(){

    $(".edit").click(function(event) {
    event.preventDefault();
    var data = {"box":1233,
   "size":565,
   "itemname":565,
   "potency":876,
   "quantity":234};

            $.ajax({
            url: "dd.php",
            type: "post",
            data: data,
            dataType: "json",
            success: function(data) {
            if(console){
    console.log(data);
}
            },
            error: function(data) {
            if(console){
    console.log(data);
}
            }
            });
        });
    });

PHP strtotime困境 - php

有人可以解释为什么这在我的服务器上输出为true吗?date_default_timezone_set('Europe/Bucharest'); var_dump( strtotime('29.03.2015 03:00', time()) === strtotime('29.03.2015 04:00�…

PHP-全局变量的性能和内存问题 - php

假设情况:我在php中运行一个复杂的站点,并且我使用了很多全局变量。我可以将变量存储在现有的全局范围内,例如$_REQUEST['userInfo'],$_REQUEST['foo']和$_REQUEST['bar']等,然后将许多不同的内容放入请求范围内(这将是适当的用法,因为这些数据指的是要求自…

PHP Count数组元素 - php

嗨,有人可以解释为什么这会返回“数组由0个元素组成”。 :$arr = array(1,3,5); $count = count($arr); if ($count = 0) { echo "An array is empty."; } else { echo "An array has $count elements.…

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

PHP:从函数返回值并直接回显它? - php

这可能是一个愚蠢的问题,但是……的PHPfunction get_info() { $something = "test"; return $something; } html<div class="test"><?php echo get_info(); ?></div> 有没有办…