ajax、php、json异步数据处理

来源:互联网 发布:北京知境科技有限公司 编辑:程序博客网 时间:2024/06/07 19:27

ajax


<script type="text/javascript">

var zp_url = "http://hjzj/weldhome/index.php/img/index";



$.ajax({

url:zp_url,

type: 'post',

data:{

"content":'<?php echo $content;?>'

},

dataType:'json',

cache: false, 

error: function(){ 

alert('出错了!'); 

return false; 

}, 


success:function(json){

var a = json.content;

$('.TEXT').html(a);

},

  

});


</script>



php


public function index(){

$content = $_POST['content'];

//$str = base64_encode($str);//编码

$str = base64_decode($content);//解码


$arr = array('content'=>$str);


echo json_encode($arr); 


}

0 0
原创粉丝点击