Reputation: 177
<script>
var numx = 5000;
alert('${myCustomTagLib(number:"numx")}')
</script>
How to pass javascript varable "numx" to gsp tag?
Upvotes: 0
Views: 1537
Reputation: 2895
You cannot do like that way but you can do it with ajax
$.ajax({
type: "POST",
url: "/someController",
data: { number: numx } // here send the data to your controller and process it
})
.done(function( msg ) {
// display the processed data here
alert( msg );
});
Upvotes: 1
Reputation: 1153
You clearly needs to understand, when GSP is executed and when JavaScript is executed.
Execution of GSP happens in the server. At this point, there is no JavaScript variable to assign. So your "numx" in always null, when "myCustomTagLib" is called.
Upvotes: 5