473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

changing image source

ok, I am just learning this stuff, small stupid question here...I am
trying to swap images in a little ajax application, and the code
handling that looks like...
document.placeholder.src =xmlHttp.responseText
/
no big deal i know, if i print xmlHttp.responseText to the screen the
link is correct, but anytime I assign it as a src, i get the link+(all
the page html attached on the end) and i dont know why?

this is driving me crazy

May 2 '06 #1
8 2329
da***********@gmail.com said the following on 5/2/2006 11:17 AM:
ok, I am just learning this stuff, small stupid question here...I am
trying to swap images in a little ajax application, and the code
handling that looks like...

document.placeholder.src =xmlHttp.responseText
I hope placeholder is an image tag....

document.images['placeholder'].src is less ambiguous.
no big deal i know, if i print xmlHttp.responseText to the screen the
link is correct,
What "link" is correct? Are you trying to create a link or change an image?
but anytime I assign it as a src, i get the link+(all
the page html attached on the end) and i dont know why?


Problably something in the responseText doesn't close a tag. Or,
something else is screwing it up.

Post a sample page URL that has your code in it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 2 '06 #2
ok, since this is a little ajax thing, i have it handling the response
like this

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.images['placeholder'].src =xmlHttp.responseText
}
}

now, if i change it to write a message based on the xml response, it
displays like it should, only with the image it screws up...

if i just do document.write(xmlHttp.responseText) it prints out:

http://static.flickr.com/48/131196335_d17ea359ff_s.jpg ----> THIS IS
CORRECT
http://static.flickr.com/48/131196335_d17ea359ff_s.jpg%3C!DOCTYPE%20html%20PUB LIC%20%22-//W3C//DTD%20XHTML%201.0%20Transitional//EN%22%20%22http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%20%3E%3Chead%3E%3Ctitle%3EUntitled%20Page %3C/title%3E%3C/head%3E%3Cbody%3E%20%20%20%20%3Cform%20name=%22for m1%22%20method=%22post%22%20action=%22data.aspx?q= david%22%20id=%22form1%22%3E%3Cdiv%3E%3Cinput%20ty pe=%22hidden%22%20name=%22__VIEWSTATE%22%20id=%22_ _VIEWSTATE%22%20value=%22/wEPDwUJNzgzNDMwNTMzZGSp104ewJZW3kxaiJAD/zBqXoBxJQ==%22%20/%3E%3C/div%3E%20%20%20%20%3Cdiv%3E%20%20%20%20%20%20%20%2 0%3C/div%3E%20%20%20%20%3C/form%3E%3C/body%3E%3C/html%3E

---->this is not...
what is happening?

May 2 '06 #3
that didnt seem to do it...i am really confused by this, it will print
out the string fine, but as soon as I try to assing the URL to a photo
as its source, it gets jumbled...

May 2 '06 #4
david sargent wrote on 02 mei 2006 in comp.lang.javascript:
that didnt seem to do it...i am really confused by this, it will print
out the string fine, but as soon as I try to assing the URL to a photo
as its source, it gets jumbled...


Please quote what you are replying to. This is not email, but usenet.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 2 '06 #5
i am sorry, new to google groups...
Evertjan. wrote:
david sargent wrote on 02 mei 2006 in comp.lang.javascript:
that didnt seem to do it...i am really confused by this, it will print
out the string fine, but as soon as I try to assing the URL to a photo
as its source, it gets jumbled...


Please quote what you are replying to. This is not email, but usenet.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


May 2 '06 #6
david sargent said the following on 5/2/2006 5:37 PM:
that didnt seem to do it...i am really confused by this, it will print
out the string fine, but as soon as I try to assing the URL to a photo
as its source, it gets jumbled...


I will refrain from repeating what Evertjan said about quoting, but
please don't top post either.

Try setting a variable to the responseText, alert that responseText, and
then set the src to the variable:

myVar = xmlHttp.responseText;
alert(myVar);
alert('typeof myVar is ' + typeof(myVar));
alert('typeof xmlHttp.responseText is ' + typeof(xmlHttp.responseText));

What do the two typeof's give you?
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 2 '06 #7
> Try setting a variable to the responseText, alert that responseText, and
then set the src to the variable:

myVar = xmlHttp.responseText;
alert(myVar);
alert('typeof myVar is ' + typeof(myVar));
alert('typeof xmlHttp.responseText is ' + typeof(xmlHttp.responseText));

What do the two typeof's give you?

Both say typeof string, but when the alert(myVar) pops up, it shows the
additional text on the end...when I just do a
document.write(xmlHttp.responseText) it gives me just the url...

May 3 '06 #8
david sargent wrote on 02 mei 2006 in comp.lang.javascript:
i am sorry, new to google groups...


That be as it is,
but comp.lang.javascript is NOT a Google group,
it is a Usenet goup.

Google is only the portal you use.

Better use a dedicated news-reader.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 3 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lazarus Plath | last post by:
I've made a gallery that has thumbnails along the top and clicking them changes the source for the full size image below, but it seems I can't change the image size. A workaround I made up is to...
2
by: Paolo Pignatelli | last post by:
I am trying to get an output/file like this (below) in an XML file (MyXmlFile.xml) (which I will use for a slide show) -- <gallery timer="3" order="sequential" fadetime="2" looping="yes"...
3
by: SGA Smele | last post by:
Hello, Now I think that there is a simple answer to my problem, but I don't know what it is and I can't work out what I should be searching for on the internet to read up some more about it. ...
3
by: Maxi | last post by:
All areas surrounded to the center area has files Thumbnail1.jpg......Thumbnail8.jpg. What I want to do is whenever user moves his/her mouse in Thumbnail 1 area, the center area should show...
1
by: Chuck Anderson | last post by:
I'm using a simple, pseudo progress bar. Very simply, I display a still image next to a form submit button until the user clicks on it, and then I change the image source to an animated version of...
3
by: bulldog8 | last post by:
I am having problems with changing a frames source file for Mozilla (1.5.0.4). The followig code works for IE: <script type="text/javascript"> var imgP = new Image(); function...
4
by: dreaken667 | last post by:
I'm using this javascript: var curr_type="adherence"; function update(){ var r=document.getElementById("range").options; var range=r.value; if(range!="L7D"){...
1
by: nt5515 | last post by:
hey Im trying to make a game of pairs (the memory game) i have set up a grid which displays a graphic for the card back. im trying to link the edit menu to choose the graphic to be displayed. i've...
7
by: Trastabuga | last post by:
I have a simple task: I need to change image src on the fly and then get its new width and height; var url = "/some/request"; var img = document.getElementById('my_img'); var old_width =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.