Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass a html with javascript variable as a json object?

 
Deepshan Shetty
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,



I need to do the above. I get an error while passing the javascript variable. Is there any other way to do the above. I have tried with escape characters but it doesn't work.
This I'm doing as a part of datatable where I need a column with a button only for some row with a specific condition.

Thanks and regards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have not provided enough context to answer the question. And, I see nothing in the way of JavaScript here -- did you mean a JSP variable?
 
Paul Clapham
Sheriff
Posts: 21572
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Context" would mean things like the error message, the component which produced the error message, stack trace if any, relevant code, and so on.
 
Deepshan Shetty
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for not providing required details. i have attached a snapshot of how it looks when the datatable executes.

It gets executed as below. This i get while debugging from the firebug window
[b]<button 'verify('''<%="encverify%" onclick="">''');'''>Verify</button>[/b]
verify.png
[Thumbnail for verify.png]
 
Dave Tolls
Ranch Hand
Posts: 2102
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly are you trying to achieve?

For starters, why is there a JSP scriptlet in the HTML you are sending to the client in a JSON response?
Scriptlets (apart from being a Bad Idea) are handled on the server when a JSP is executed, so nothing is going to be done with this one.

So, again, what are you trying to achieve? Not how...what.
 
Deepshan Shetty
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The table is built on datatables concept to which the values are passed in a json format.
But (as in the image) for transaction which has status as Request_Sent i need to have a verify button to which i have to pass a set of parameters.

Im not able to achieve this? Can you please suggest something?
 
J. Kevin Robbins
Bartender
Pie
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm struggling to understand what you are doing, but button actions are usually managed by binding to the click event.



This way the button function fetches the values to be validated.

There are also jQuery plugin validation tools which may help.

Does this help?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The bottom line is that, no, you can't send an HTML fragment to a page that contains a JSP scriptlet and expect it to be evaluated. Such evaluation happens on the server. Please read this article to understand how JSP works.

And, of course, you shouldn't be using scriptlets at all. They've been obsolete for 15 years.
 
Deepshan Shetty
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not a scriptlet. That's a part of my servlet code
 
Dave Tolls
Ranch Hand
Posts: 2102
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's this?

if it's not a scriptlet?

What is this supposed to do on the client (which is the only place that can do anything with it)?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic