getting data to display as html nodes and not as text |
getting data to display as html nodes and not as text |
larry wales |
Oct 1 2007, 07:17 PM
Post
#1
|
Group: Members Posts: 1 Joined: 1-October 07 Member No.: 3,958 |
Hi,
I'm working on an ecommerce application for school and am trying to get a simple AJAX function to query database and return some images to a web page. So far, I've managed to successfully do all except for the final step: I can't manage to get the returned data to appear as thumb images in the document. I am 100% certain that the returned data is: <a href="?id=1"><img src="images/thumbs/1.1.png" class="thumbox" /></a>; The callback function I'm using is:
This produces the following error: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://localhost:8084/kramekznamek/js/javascript.js :: callback :: line 22" data: no] I'm fairly sure the problem lies in using the right method with 'id'. Also, interestingly enough, if I type in "document.write(request.responseText)" as a test, I see exactly what I'm wanting: two thumb images. If anyone has any suggestions, I'd be really grateful thanks, larry |
Frederiek |
Oct 2 2007, 03:03 AM
Post
#2
|
Programming Fanatic Group: Members Posts: 5,146 Joined: 23-August 06 From: Europe Member No.: 9 |
Maybe you'll find an answer from one of the links at http://www.d.umn.edu/itss/support/Training...cript.html#ajax.
|
Christian J |
Oct 2 2007, 09:21 AM
Post
#3
|
. Group: WDG Moderators Posts: 9,663 Joined: 10-August 06 Member No.: 7 |
if I type in "document.write(request.responseText)" as a test, I see exactly what I'm wanting: two thumb images. Could it be that it's a string? You can test that with the nodeName property: http://www.quirksmode.org/dom/w3c_core.html AFAIK you can't use appendChild with strings, instead you must create an element and give it attributes and values using DOM methods. See http://developer.mozilla.org/en/docs/Trave..._DOM_Interfaces If you must use a string you might use the innerHTML property instead of the DOM. Of course none of this will work for users with JS disabled... |
Lo-Fi Version | Time is now: 4th May 2024 - 04:30 PM |