• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not a scriptlet. That's a part of my servlet code
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)?
reply
    Bookmark Topic Watch Topic
  • New Topic