天天看點

php+jsonp+[jquery]

不使用jquery——

<script type="text/javascript">

function say(words) {

    alert(words);

}

</script>

<script type="text/javascript" src="http://test/index.php?callback=say"></script>

伺服器端:index.php:

<?php echo $_GET['callback'].'("Hello, everyone!");'?>

使用jquery——

用戶端:

$(function(){

    $.getJSON(

        'http://test/index.php?callback=?',function(words){

            alert(words);

        }

    );

})

伺服器端:index.php:

<?php echo $_GET['callback'].'("Hello, everyone!");'?>