Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending Javascript from server to execute on client side.

 
samir ware
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers
Is it possible to send some bunch of javascript function from server and then get them executed one ofter another on client side?I am aware of eval function which does this job but I am not sure as to what should be the parameter to eval if I am requesting to a JSP from client to get all those function which I need to get to get executed on client side. Do I need to write the code to extract the javascript code from the response and then do manupulation on response so as to get all the list of comma seperated JS functions which I can pass to eval ? Any white paper link will greatly be appreaciated.
Thanks
Samir
 
Paul Clapham
Sheriff
Pie
Posts: 20184
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course it is. All the Javascript in your pages comes from the server already. So perhaps you could be more specific about what you actually want to achieve.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without mentioning how the script is being fetched, no answer is possible. Is this using Ajax? JSP includes? What?
 
samir ware
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul, Bear
Thanks a lot for the reply. I am going to fetch javascript there by making AJAX call to a JSP. This JSP is meant specifically for sending some information to the client in javascript array . Though I am not sure as to how I can access the ONLY the js function from the response and evaluate these
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use JSON?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using jQuery to do your Ajax for you (and have set the response type to HTML), any script blocks in the response will be automatically executed.

If you are doing your Ajax "by hand", you've got a big job ahead of you... You'll need to find all the script blocks yourself and cause them to be evaluated.
 
samir ware
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ahhhhh....All rt Bear...Thanks a lot for the kind help
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic