• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Dynamic loading with AJAX

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have requirement where I have to load the content of JSP dynamically. And this has to happen within the single page.




now my problem in from the layout tree a tree will be displayed dynamically after the button on the top portion of the page. Once the tree is loaded a link will come called 'Add New Node' on click of which i need to replace the content of div - 'nodeDetailsDiv' with the html generated from another JSP. and that has to be used to save the data to db. I am using ajax here for the call.


Above is the script for dynamic loading. But document.getElementById('nodeDetailsDiv').innerHTML = req.responseText; at this line i am getting an error stating 'Unkonwn runtime error.'

Please help
Thanks and regards
Dilip
 
Sheriff
Posts: 67590
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
Is there any valid reason that you are not using jQuery to perform the Ajax? It will likely do what you want with one line of code.
 
Dilip H Pashupathi
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

Can you please let me know about jQuery, as I am new to jQuery and AJAX, if possible to begin with novice level of how to's. I have studied a bit on ajax but not fully sure of how to work with it.

And in Ajax call the if page being loaded contains "form" element then also this will generate a run time error. My requirement is I already have a form associated with a jsp, now i am loading
a secondary jsp containing another form element. for example DoctypeEdit.jsp is one where i have some fields that are to be entered by user, once he clicks on proceed button, another jsp will be loaded called TreeView.jsp, where an xml tree will be shown in the form of collapsible format.

Now here in this tree I have added a link called "Add New Node" on click of which an ajax call has to happen which hits the action classes and fetches few details from db. Once details are fetched the data will be displayed in form of drop down list. And these dropdown lists are supposed to be in a "<form>" element.

But if I include the form element in third jsp i.e "CustomNodeDetails.jsp" ajax call fails and throws a Unknown runtime error.


Thanks and Regards
Dilip
 
Bear Bibeault
Sheriff
Posts: 67590
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

Dilip H Pashupathi wrote:Can you please let me know about jQuery


Well, I wrote an entire book on jQuery, so it's not something you're going to learn from a forum post. There are lots of good resources out there.

as I am new to jQuery and AJAX


Without jQuery (or some other library) Ajax can be a nightmare. But with kjQuery, fetching an HTML frgament from the server and loading intot he DOM is as simple as this statement:It's that simple.

If you are going to be working with JavaScript in the browser, I highly recommend getting to know jQuery.
 
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