aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Regarding implementing JQuey.load() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Regarding implementing JQuey.load()" Watch "Regarding implementing JQuey.load()" New topic
Author

Regarding implementing JQuey.load()

indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
My first sample program using JQuery... try to insert test1 -text box value through jsp,...but ends up with javascript error - unexpected call to method.
in jsp, "name" parameter is printing..

TestJQ.jsp


thanks,
indu
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please indent your code properly; without proper indentation JavaScript becomes rather difficult to read. It'd also be easier if you didn't use a leading "$" in your variable names--it's noisy and somewhat confusing.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Are you returning XML?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Using $ in variable names is not a best practice in JavaScript.
You are mixing getElementById and jQuery, not sure why you did that.

Description of load from jQuery's site: Load data from the server and place the returned HTML into the matched element.

What browser is the error happening in?
When you call the jsp page directly, is it loading in the browser? [Type jsp url into browser]

Eric
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
Ok.. I deleted the messy part. Now I just want to get one string from jsp, and should be placed in an empty textbox in html.

In browsers -- firefox - not showing any result,
IE - alerts whole jsp page,
eclipse editor - alerts the error " unexpected call to method or property access"


Please tell me is this the correct way to send a string to html ?
TestJQ.jsp
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

So there are all sorts of issues here with your code. First, you seem to be expecting XML returned from the $.load() function. That may very well be however, the $.load() doens't give 2 beans about the data. It just simply dumps it into the selector you've chosen. Secondly, you're overcomplicating the JSP....



And the TestJQ.jsp



Honestly, that's all there is to it.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

If you are expecting XML in return and you need to parse it, you won't be able to use $.load(). You'd be better of with $.get()/$.post()
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
Then how to load the text box, actually I have a dropdown box in html,
to be loaded from database (in jsp).
Todo this, I just tried with this small example.
ok, here am trying the populate textbox, whose value has to be populated from jsp,,
Jsp code :::

eventhough , it is not populating ...
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

There is no such thing as a 'textbox' in HTML. What HTML element are you trying to populate? Hint: Show us.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Ah, I just re-read everything. What you are trying to do doesn't work. $.load() won't populate input elements. What you need to do is something like this...



Assuming you want to populate:

indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
thank you, thank you Gregg, working fine..
Is this the same way to work with dropdown box ?, in which array of strings has to be populated !!!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

indu yeturu wrote:thank you, thank you Gregg, working fine..
Is this the same way to work with dropdown box ?, in which array of strings has to be populated !!!


That's one way, yes. But you would be better off returning the options for the select as JSON. It's much easier to work with in JavaScript.
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
Thank you ... I will try with JSON...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding implementing JQuey.load()