tags:

views:

68

answers:

1

AJAX is a very powerful tool so I am struggling with it :-).

Is there any way or API(in java) so that I can get the HTML code which is generated by AJAX?

Generally, AJAX make use of inner HTML code and hence this inner HTML code is missing when I look into the page source of a page.

e.g click here

Just see the section OTHER NEWS. The content is populated by AJAX. When I look into the page source the code is not there.

I need this HTML code through a java program. How can I get it?

+3  A: 

To have a Java application use the content received via AJAX, you need to first find the URLs from where the content is getting called from. In case this it would be http://itm2083.com/get%5Fwwo%5Fcontent.php?featureGroupId=8355&featureDisplayLimit=1&sponsorName=vortalx&wwoDivCounter=5&domainUrlForWWo=http%3A//item2083.com/&featureImgDisplay=FLAG%5FTRUE&featureGroupImageWidthLimit=200&featureGroupDefaultImageUrl1=http%3A//wwo.itmftp.com/75x75.gif&featureGroupDefaultImageUrl2=http%3A//wwo.itmftp.com/75x75.gif&featureGroupDefaultImageUrl3=http%3A//wwo.itmftp.com/75x75.gif

The featureGroupId= parameter has 5 IDs: 8355, 8359, 8367, 8369, 8429. Use these to pull the content from the Other News box.

The featureDisplayLimit= parameter determines how much content is pulled from the server.

If you want the nice HTML as well, the Java app will have to recreate it, as the HTML rendered on the site is created by JavaScript code.

KramerC
Yes I can do even I did also but this not what I'm looking for. Its a manual process. I need to write a java program which will do the same as firebug and give me the Ajax generated elements.
Ritz
Hmm why not have the Java program use the URL made by the AJAX Request instead. It should work if the AJAX Response gives HTML.
KramerC
Means I've to look into complex .js files and try to get the URL. But again this a manual process. I need an automated one like HtmlUnit API. But it doesn't give good support for ajax calls.
Ritz
Hmm I'm looking for what you could possibly do. The site's coding is horrible and the Other News ticker doesn't even work in Firefox. It appears that the content is from http://itm2083.com/
KramerC
Thanks for the support :-)
Ritz
KramerC
These are the feature group IDs the content is using are 8355, 8359, 8367, 8369, 8429
KramerC
That great. +1 for it. I guess you are very near to the solution.But the link you just mentioned gives me just 1 contentID. Just have a look into the linkhttp://www.wrta.com/page.php?page_id=17598
Ritz
KramerC
Thanks for the support. I'll recreate the content into HTML. I need all the content populated in that particular <div>. The link you mentioned doesn't provide the information but that is of great help.
Ritz
You need to change the featureDisplayLimit parameter.
KramerC
You are simply AMAZING! Thanks a lot. Just last question. How you created that link?
Ritz
Google Chrome has a Script debugger and it was showing me the content URL in the list so I was able to take that. Normally AJAX requests would show in the Console in Firebug, but the thing was broken in Firefox.
KramerC
Thats cool :-) Means I should use Google Chrome also.Thanks again. It was of great help. You jumped from 11 to 36 :-)
Ritz
I normally use Firefox. No problem. :)
KramerC
A very fine example of kindness, determination and passion. +100 (wish I could do that).
Adeel Ansari