javascript - Pass external var to jquery function -
html file:
<head> //include jquery </head> <body> //html stuff <script type="text/javascript"> var prd = 'something'; </script> <script type="text/javascript" src="script.js"></script> </body>
script.js
$('#select span').click(function(){ var id = this.id; var path = '/scripts/test/sqlgetdata.php?id='+id+'&p='+prd; path = encodeuricomponent(path); post(path); }); function post(path){ //stuff }
the var prd
not avaiable on function include in var path
.
i've alse tried:
$('#select span').click(function(prd)
is possible solve without callback? thank you
it's passed event.data
$('#select span').click({prd: prd}, function(e){ var id = this.id; var prd = e.data.prd; // here var path = '/scripts/test/sqlgetdata.php?id='+id+'&p='+prd; path = encodeuricomponent(path); post(path); });
Comments
Post a Comment