• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Sending Javascript from server to execute on client side.

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 26912
82
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
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.
 
Sheriff
Posts: 67596
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
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use JSON?
 
Bear Bibeault
Sheriff
Posts: 67596
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
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ahhhhh....All rt Bear...Thanks a lot for the kind help
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic