Thank binary heaven for this site! I'm trying to oil my rusty Java wheels again, and could really use some direction. The objective I am trying to achieve is to fetch Blog posts from Blogger, and my code is getting hung up somewhere.
Setup: JSON/AJAX in a JS page; called in JSP page.
This is the code to pull blog summaries for each posting:
And this is the code to call the function in the JSP Page:
Any thoughts are greatly appreciated. I think my index check at the end may be set up incorrectly, but then again, this whole design is probably outdated....
Little Butterfly wrote:I'm trying to oil my rusty Java wheels again...
What I would recommend at this point is to open up the browser's debugger, set a breakpoint at the function, and step through it to see where what it is doing deviates from your expectations.
Little Butterfly wrote:And this is the code to call the function in the JSP Page...
I'm not seeing any calls to the function in your code. Are you sure it's being called in the first place?
This line does not make sense:
$.support.cors is intended to tell you whether the browser supports CORS or not. Changing its value to true has no effect except to override the actual setting if false.
You are obviously using jQuery for much of the code, yet rather than using jQuery DOM manipulation to create new elements, you are building up HTML in strings:That's, ummm, well, odd and not a great way to do it.
Good chilly day! Hibernating in a 2ft' snow blizzard , but I'm still at it! Thank you for pointing out that very sore spot, a very silly error to make. #green
I appreciate all the observations, helpful hints, etc, and have been using them to improve on my code over the weekend.
A bit of context:
Unfortunately, I'm starting from another developers code, and a lot of this doesn't make sense. I'm not very experienced, but I know that it is bad practice to have <%scriptlets%> governing a majority of a JSP. The end product is being imported into SAP Portal as a web application. So unfortunately, some of this backward coding may be necessary...
I've been taking pieces of code bit by bit and trying to improve.
Here is my (hopefully) improved code. I took the HTML strings and created(AN ATTEMPT!) DOM elements for the 'items' processing*. 'items1'& 'items2' are utilized in proceeding elements to complete appending tasks:
I still have not been able to get a break-point in to do the browser debugging. Any additional constructive criticism? I appreciate your time and expertise!
None of my programs are allowing me to add breakpoints to review the functions in the system... Though the real issue may be I don't know how to set this up properly:
This is what I see when I try to click events in the console. Do I need actual document. statements for this to work?
(P.S. All of these recent weather systems are unnatural, there's been a total of 20 inches in Missouri so far, lowest temp of -20F, and it's snowing again today. Yes, 21 is terribly cold for the south! Egypt got snow too, last time was over 200 years ago...Hmm.)
Thank you both for the reply!!
Thank you for your assistance..... My recent progress awards only 7 feet on my neck, instead of 8. haha.
After spending yesterday I'm doing a bit better. The Web Inspector helps a bit, and by a bit I probably mean a lot.
I've completely reconstructed my code (again!) and now trying to get it to display properly in my application project:
Looks like my programming logic is slightly improving already! NOW. The issue that I'm having is getting this project to run in a package I am creating with SAP's version of Eclipse, described in following post:
Don't do document.write, that will replace the currently loaded document. You should grab an element with document.getElementById and then append your new content to it, or use jQuery and appendTo as you were doing originally. Also, replacing newlines with spaces is redundant because that happens anyway when you add the text to an HTML document.
The main js initializes project and fetches the necessary data as well as the blog post function:
During functions processing, fetchBlogPost is instantiated, and its results should be returned to a div id "latestBlogEntry" that is also specified in the main JSP.
Here's the Initializing statement, aka "ON" switch:
The main JSP has the div setup to receive the play:
with the script call at the end.
I really can't figure out how to test this, as html is needed to use the inspector. Any helpful hints or direction from you kind hearts?? I have the package available, so I can give more code or supply it if necessary...
And in response to replacing line breaks... there is one particular section that I've gotten hung up on in my previous builds, maybe you can shed some light there too? The best result I've gotten firing this code up successfully is one sentence. After that sentence in the API, you can see a bunch of styling and line breaks, and this particular case may need something extra:
Is there a better way to try and get the rest of this post to feed through?
I wanted to update this post with my progress, in case anyone look through this in the future.
All document.write() tags have been replaced with a .push() into the HTML element for the blog. Yes the ugly concatenation is necessary for this project, because the Portal environment seems to hang up on passing my json object via ajax, I may be wrong here but I can get this code to run 99% as expected in the enterprise software:
The last piece is the date format. I am trying to pull a full date with weekdays, and in IE the object is returning undefined, NaN NaN:
Is there something I can add to this code so that IE would recogize this without the T character? Another solution I found that I may integrate is adding something like this:
Any additional thought are greatly appreciated. Having this site and a few trusty books as references has helped me to think outside the box.