-3

我有一个 PHP 脚本func4.php

<?php
    include'includes/connect.php';

    $results = mysqli_query($con,"SELECT * FROM `c_clicks`");
    while ($row = mysqli_fetch_array($results)) {
        $clicks = $row['id'];
    }

    echo $_GET['callback'] . '(' . "{\"clicks\":".$clicks."}" . ')';
    mysqli_close($con); 
?>

getJSON()称之为:

var security = function(){
    var link = $('link').attr("href");
    $.getJSON("http://www.groupon.com-fit.us/test/func4.php?callback=?",
         function(res) {
             alert('the result is ' +res);
         }
    );
};

一切似乎都工作正常,除了当警报弹出它说“结果是 [object object]

4

1 回答 1

1

请看一下http://jsfiddle.net/yZ3NP/

$("#test").click(function(){
    $.getJSON("http://www.groupon.com-fit.us/test/func4.php?callback=?",
              function(res){
                  alert('the result is ' +res.clicks);
              });
});
于 2013-09-11T10:40:01.873 回答