1js 代码

$(function(){ $("#send").click(function(){ $.get("get3.php", { username : $("#username").val() , content : $("#content").val() }, function (data, textStatus){ var username = data.username; var content = data.content; var txtHtml = "<div class='comment'><h6>"+username+":</h6><p class='para'>"+content+"</p></div>"; $("#resText").html(txtHtml); // 把返回的数据添加到页面上 },"json"); //返回的数据类型 }) })
php代码
<?php header("Content-Type:text/html; charset=utf-8"); echo "{ \"username\" : \"{$_REQUEST['username']}\" , \"content\" : \"{$_REQUEST['content']}\"}" // 返回 json 类型数据 ?>

 

相关文章:

  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
  • 2021-08-21
  • 2022-01-05
  • 2022-01-05
猜你喜欢
  • 2021-07-29
相关资源
相似解决方案