0

I have a function like this :

$(document).ready(function () {
    var loading = $("#loading");
    var tampilkan = $("#tampilkan");

    function tampildata() {
        // membuat efek fading
        tampilkan.hide();
        loading.fadeIn();

        $.ajax({
            type: "POST",
            url: "<?=base_url()?>ppat/data_pengangkatan/<?=$row->idppat?>",
            data: "aksi=tampil",
            success: function (data) {
                loading.fadeOut();
                tampilkan.html(data);
                tampilkan.fadeIn(2000);
            }
        });
    }
    tampildata();

    $("#save").click(function () {
        tampildata();

    });
});

function makeAjaxCallInsert() {
    $.ajax({
        type: "post",
        url: "<?=base_url()?>ppat/pengangkatan_insert/<?=$row->idppat?>",
        cache: false,
        data: $("#userFormInsert").serialize(),
        success: function (json) {
            try {
                var obj = jQuery.parseJSON(json);
                alert(obj["STATUS"]);
            } catch (e) {
                alert("Exception while request..");
            }
        },
        error: function () {
            alert("Error while request..");
        }
    });
}

I wish that every page on load data contained participate. in the above script can be run after loading the data store data only. I hope someone can help me.

Praveen
  • 55,303
  • 33
  • 133
  • 164
mayus
  • 53
  • 2
  • 11
  • I don't know if I've understood you correctly but are you looking to do something only once the ajax call has completed? If so, refer to http://api.jquery.com/jQuery.ajax/ on the 'complete' and 'success' settings – Joe Spurling Jul 08 '13 at 05:21
  • So, what is happening now and what do you expect? Please also confirm that this script is inline in your server side script page. – vee Jul 08 '13 at 05:22

1 Answers1

0

See this: http://jsfiddle.net/h255Q/

1) function tampildata() must be outside of $(document).ready(function () {

2) var loading = $("#loading"); must be define inside function OR must remove var at begin of!

3) and should be read a programming book, my Indonesian friend!

EmRa228
  • 1,226
  • 13
  • 22