Pasing value from PHP to javascript using ajax, jquery, JSON

$jumlahOrderBaruMasuk =0;
$jumlahOrderBaruMasukAlquran = MOrderAlquran::jumlahOrderBaruMasuk();
$jumlahOrderBaruMasuk = $jumlahOrderBaruMasuk + $jumlahOrderBaruMasukAlquran ;

$jumlahOrderBaruMasukPoster = MOrderPoster::jumlahOrderBaruMasuk();
$jumlahOrderBaruMasuk = $jumlahOrderBaruMasuk + $jumlahOrderBaruMasukPoster ;

if( $jumlahOrderBaruMasukAlquran > 0){
MOrderAlquran::ubahStatusNotifikasi();
}

if( $jumlahOrderBaruMasukPoster > 0){
MOrderPoster::ubahStatusNotifikasi();
}

echo json_encode(array('jumlahOrderBaruMasuk' => $jumlahOrderBaruMasuk));
var page = "ppic/perhitunganMaterial/notifikasi";
$.ajax({
url: site+"/"+page,
type:"post",
dataType:"json",
success: function(html){
var jumlahOrderBaruMasuk = html.jumlahOrderBaruMasuk;
if(jumlahOrderBaruMasuk>0){
popup_notifikasi();
}
}

});

http://forums.phpfreaks.com/index.php?topic=320918.0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: