Dear All I am using Javascript JQuery and PHP. My doubt isHow to limit the javascript function to execute once?
My MainJQuery file has ajax, display.php ,it execute for a while
....
$.ajax({
type:'POST',
url: 'display.php',
data:'id='+id ,
success: function(data){
$("#response").html(data);
//Here Get_list should be execute only once
get_list('get');
// display should execute as usual
display();
}//success
}); //ajax
.......
get.Php file writes value to Javascript
<?php
print "<script language='javascript'>";
print " g_cost[g_cost.length]=new Array('STA-VES','East',4500);";
print " g_cost[g_cost.length]=new Array('STA-CRF','West',5400);";
print "</script>";
?>
My Javascript function has following value from php
function get_list('get'){
for(var i=0;i<g_cost.length;i++)
var temp = g_cost[i];
var Name = temp[0];
var direction = temp[1];
var cost = temp[2];
..
some code
...
}
function display(){
for(var i=0;i<g_cost.length;i++)
alert(g_cost.length);
var temp = g_cost[i];
alert(temp[0]);
alert(temp[1]);
alert(temp[2]);
}
Is it possible limit to Execute a javascript function ,In JQuery ajax Success Portion; Any way to do this?