simple codeigniter ajax Json encode cuy

simple banget y, tapi untuk belajar cool ajah, silah dicoba y


ada eror alertnya cuyyy ,,.. cekidot y

di controller write this below ===


<?php

class Api extends CI_Controller {

public function simple(){

$data = "testJsonEncode cuy";
echo json_encode($data);
}

public function simpleAjaxJsonEncode(){

$this->load->view('vAjax');
}

}

di view nya cuy ===

<HTML>
<HEAD>
<script type="text/javascript" src="<?php echo base_url()?>jquery-1.9.1.js"></script>
<script>
function Call(){
$.ajax({
type: "post",
url: "<?php echo site_url('api/simple')?>",
cache: false,
success: function(json){
try{
alert(json);
}catch(e) {
alert('Exception while request..parsing cuy');
}
},
error: function(){
alert('Error while request..url cuy');
}
 });
}
</script>
</HEAD>
<BODY>
<input type="button" onclick="javascript:Call();" value="Submit"/>

 </BODY>
</HTML>





selamat mencoba cuyyyy !!!!!

0 Response to "simple codeigniter ajax Json encode cuy"

Posting Komentar