File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i dynamically load the jQuery javascript library without using ajax

 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey I came across the need to load jQuery based on an event after a basic html page had already loaded. I don't want to load jQuery the moment my Html page loads for whatever reason and at some moment or on some event i wants to load jQuery how can i do it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like an odd thing to do, but you can construct a script tag for the jQuery library and add it to the DOM.
 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i call the perticuler jquery function in Html page at perticular moment.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like at *what* "particular moment"? I mean, jQuery is just a library--you can call its methods whenever you want.
 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the moment i means that at perticular event. This had to be done synchronously with any other code which depends on jQuery.
Maybe we have a simple html page or other small file and we don't want to load jQuery the moment this file loads for whatever reason.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Seems like an odd thing to do, but you can construct a script tag for the jQuery library and add it to the DOM.
 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey by searching on internet i saw this example can you explain it

step - 1

 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
step - 2

 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
step - 3


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Next time, single post--people stuffing the ballot box in an attempt to win free stuff are frowned upon.

The code does what Bear told you you could do.
 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey david that's not way to win free stuff. i wants to ask the solution of my query. If you thinks that your welcome. I am an beginer not expert i saw this code on internet and not understand in detail i understand only that it is calling jquery code from the page but what is it doing in step 3.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David means you can (and you should) post your code in one single post, not in three different posts.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google also host the jQuery libraries. While it doesn't tackle the exact problem asked in the OP, it does two things,

1. Saves you the hosting and bandwidth.
2. Saves your end user a download of the library, if its already there from any other site they have visited (and uses Google as Host)

I guess the scenario in which the OP becomes useful is case #1 (is just a guess, what else is Dynamic loading of the library useful for if not to save some bandwidth?)
 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@john todd ok... i will remember next time. i post it in diffrent posts cause i wants to increase readability.

@sam yup i also thinks so it makes code faster to load andsaves time and save bandwith.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shashank Agarwalg wrote:@john todd ok... i will remember next time. i post it in diffrent posts cause i wants to increase readability.

It's actually less readable, though--too much vertical and cognitive disconnect.
 
Shashank Agarwalg
Ranch Hand
Posts: 110
Android Java Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok... David i ill remember next time sorry for misbehevoour . actualy i am new to javaranch i wll remember thease things next time.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem :) (Although you're not *that* new, nearly a half year now!)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic