HTML代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script> </head> <body> <script> $.ajax({ url:‘http://test.com/abc.php?name=hh&age=21‘, type:‘get‘, dataType:‘jsonp‘, jsonp:"back", success:function(data){ alert(‘姓名‘+data.name+‘年龄‘+data.age); } }) </script> </body> </html>
PHP代码
<?php $data[‘name‘] = $_GET[‘name‘]; $data[‘age‘] = $_GET[‘age‘]; echo $_GET[‘back‘]."(".json_encode($data).")"; ?>
时间: 2024-10-29 04:13:06