Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12584
| From | Scott Johnson <noonehome@chalupasworld.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | AJAX loading entire page into div |
| Date | 2012-03-10 15:32 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <jjgobh$fla$1@dont-email.me> (permalink) |
I have used ajax with success before but am having an issue I can't
track down.
I will try to make sense of this.
I have a pull down menu and when the user chooses an item it is suppose
to load the image into a div place holder.
I have tested it with passed value and it works so I know I am targeting
the right div and it displays the ID
function display(option) {
var optionId = option.value
var xmlhttp = createXMLHttpRequest()
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("emblem_image").innerHTML=optionId;
//document.getElementById("emblem_image").innerHTML=xmlhttp.responseText;
}
}
.......
}
......
But when I add the open() method it gets all buggered up
......
xmlhttp.open("GET","/php_inc/ajax_functions.php?mode=display_emblem&id="
. id,true);
xmlhttp.send();
the php page creates a simple image
....
$output = "<img src='/emblem_images/{$emblem['EmblemImage']}'
width='300px' />";
echo $output;
When I run the page directly in the browser, i get the image displayed.
http://example.com/php_inc/ajax_functions.php?mode=display_emblem&id=1
Which tells me the php code is outputting correctly.
But when it loads into the:
document.getElementById("emblem_image").innerHTML=xmlhttp.responseText;
I get a copy of the entire original html page loaded.
Heeeeelp!
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
AJAX loading entire page into div Scott Johnson <noonehome@chalupasworld.com> - 2012-03-10 15:32 -0800 Re: AJAX loading entire page into div Scott Johnson <noonehome@chalupasworld.com> - 2012-03-10 15:42 -0800
csiph-web