• 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
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Return Ajax response to JSP

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

I have written a code in Ajax, from that i will get some responseXML from the server, get the value from the xml and i need to return the value to JSP while i getting the value in jsp it's Empty. please advice


Thanks in advance,
Bala...
 
Sheriff
Posts: 67750
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
By the time an Ajax call can be initiated, the HTML page has been sent to the browser and the fact that the page was generated by a JSP is moot.

So what are you really trying to accomplish?
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
need to return Ajax response. have a look at this

 
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
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

 
David Newton
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
What are you returning the value *from* in the above code?
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
some message...
 
Bear Bibeault
Sheriff
Posts: 67750
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

Balamurugan Balakrishnan wrote:some message...


If you are going to be uncooperative, how are you to obtain any help?
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I said that "i am going to return some message from the Ajax, and process it in JSP".


sorry if anything wrong!
 
Bear Bibeault
Sheriff
Posts: 67750
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
Please read this for more information.

The more relevant details you give, the better your chances of getting help.
 
David Newton
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
No, not what are you returning, what are you returning it *from*?

The code you posted has a return statement, but it's not inside a function, so is meaningless.

You need to *do* something with the message.
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just give an alert or confirm box with the message which return from the server. for that I need to pass the message to my JSP file.
 
David Newton
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
So do that in the function you've already written. I'm not sure what the issue is.
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The issue is that the returned value was empty, it say undefined while alert the returned message.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it that you are getting alert dialog box with message 'undefined'? If so, can you post the actual xml text that is being received in the function? May be that would help us understand the issue better.

-Milind
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the XML that returns from the server.

 
David Newton
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
So... the message *isn't* empty?
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but returning the value it's alert like "undefined".



This was i have got.
 
Marshal
Posts: 28295
95
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
If the server is returning an XML document to the AJAX request, but your Javascript code which attempts to process that returned document is encountering an undefined value, then clearly there's something wrong with your Javascript code.

So have a look at that. You could even post some details here if you wanted to progress a little faster.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Balamurugan Balakrishnan wrote:here is the XML that returns from the server.



That looks like invalid xml to me. Is that the entire document that is returned?

Eric
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have return the value to some other JSP from the Javascript mentioned above.
 
Paul Clapham
Marshal
Posts: 28295
95
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

Balamurugan Balakrishnan wrote:i have return the value to some other JSP from the Javascript mentioned above.



Oh, I see. Problem solved then?
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have returned but in the JSP only It has been alert as "undefined"
 
Paul Clapham
Marshal
Posts: 28295
95
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
No, that "undefined" has to be coming from Javascript. As you know, the JSP runs on the server and generates HTML, which in this case includes Javascript. Your problem is with that Javascript. As you also know, we haven't seen any of that Javascript code. Only you have. So carry on looking at it. Good luck!
 
Milind Mahajan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Comparing the xml and the earlier Javascript code that you posted, I think there might be a problem in the way attributes are being accessed by the JavaScript code. For example, this is how I would access the value of "name" attribute of the "attribute" tag:

instead of

Hope this helps,
-Milind
 
Balamurugan Balakrishnan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for all your responses. Still i have the problem.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is about time you sit down and learn how to debug. Figure out why it is not working. Use Firebug for Firefox and set break points. If you can not do that, start adding alerts and see what is going on.

Eric
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic