jquery - How to call JavaScript function during Pageload? -


i have html page contains several pages data-role = page page1,page2 etc. trying call js method during pageload of page1 using following code

$("#page1").on("load",function () {   alert("hi")   $.ajax({           type: "get",           url: "",           data: "{}",           contenttype: "application/json",           datatype:"json",            success:  function (msg) {                                     var bprlist = '';                                     $.each(msg, function(i,v){                                         bprlist += '<li onclick="getbprdetails('+ v.bprno +')"><a href="#bprpage" data-transition="slide"><p class="title">' + v.bprno + '</p><p class="bodyele">' + v.bpr_product +'</p><p class="bodyele">' + v.bpr_details+ '</p><br/><p class="bodyele">' + v.bpr_status + ':</p></a></li>'                                                                   })                                             $("#bprlisttable").html(bprlist)                                    $('[data-role=listview]').listview('refresh');                                    },            error:    function () {                                    alert("bpr list error");                                  }         }); }); 

during execution of above function unable output during formload if call above method button click event able output. might mistake made in above code.. more worried in following code.

$("#page1").on("load",function () {  --statements }) 

 $(window).load(function () {    alert("hi")  }); 

if want results on page load,then try instead.write code outside $(document).ready(function(){});


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -