admin管理员组文章数量:1022944
I a have a jQuery ready function given below, I need to pass a value to the myLocFn()
. What I am asking is, as we are using ready function ,if it possible to pass a jsp value to myLocFn().
<script>
$(document).ready(function(){
$(".myDiv").myLocFn(); // need to pass a value here
});
</script>
I have included the js path as well <script src="myLocFn.js"></script>
.
Where the my js starts with,
(function($){
$.fn.myLocFn= function(options) {
..... // need to get the value here
I a have a jQuery ready function given below, I need to pass a value to the myLocFn()
. What I am asking is, as we are using ready function ,if it possible to pass a jsp value to myLocFn().
<script>
$(document).ready(function(){
$(".myDiv").myLocFn(); // need to pass a value here
});
</script>
I have included the js path as well <script src="myLocFn.js"></script>
.
Where the my js starts with,
(function($){
$.fn.myLocFn= function(options) {
..... // need to get the value here
Share
Improve this question
asked Feb 28, 2013 at 4:12
NidheeshNidheesh
4,56230 gold badges93 silver badges156 bronze badges
1 Answer
Reset to default 3Write a JSP variable inside script section using server code:
<script type="text/javascript">
var jspVar="JSP_value"; // use expression tag in JSP here
</script>
Then refer in your jQuery code, just like a JavaScript variable, as u assigned ur JSP value to JS variable in above line
(function($){
$.fn.myLocFn= function(options) {
alert(jspVar); //here u can see
}
Edit: Please make sure that jspVar should be defined before accessing. You can check this from the rendered HTML
I a have a jQuery ready function given below, I need to pass a value to the myLocFn()
. What I am asking is, as we are using ready function ,if it possible to pass a jsp value to myLocFn().
<script>
$(document).ready(function(){
$(".myDiv").myLocFn(); // need to pass a value here
});
</script>
I have included the js path as well <script src="myLocFn.js"></script>
.
Where the my js starts with,
(function($){
$.fn.myLocFn= function(options) {
..... // need to get the value here
I a have a jQuery ready function given below, I need to pass a value to the myLocFn()
. What I am asking is, as we are using ready function ,if it possible to pass a jsp value to myLocFn().
<script>
$(document).ready(function(){
$(".myDiv").myLocFn(); // need to pass a value here
});
</script>
I have included the js path as well <script src="myLocFn.js"></script>
.
Where the my js starts with,
(function($){
$.fn.myLocFn= function(options) {
..... // need to get the value here
Share
Improve this question
asked Feb 28, 2013 at 4:12
NidheeshNidheesh
4,56230 gold badges93 silver badges156 bronze badges
1 Answer
Reset to default 3Write a JSP variable inside script section using server code:
<script type="text/javascript">
var jspVar="JSP_value"; // use expression tag in JSP here
</script>
Then refer in your jQuery code, just like a JavaScript variable, as u assigned ur JSP value to JS variable in above line
(function($){
$.fn.myLocFn= function(options) {
alert(jspVar); //here u can see
}
Edit: Please make sure that jspVar should be defined before accessing. You can check this from the rendered HTML
本文标签: javascriptCan we pass a jsp variable to jQuery ready functionStack Overflow
版权声明:本文标题:javascript - Can we pass a jsp variable to jQuery ready function - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745595192a2158124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论