Ajax question

M

Mike

Hello
I have The following:
In my main file
<div id="txtHint"></div>
in my php file
echo "<p>$row_Recordset1</p>"
in my js
function stateChanged()
{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
// alert (xmlHttp.responseText)
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}

The element, which is correct, flashes on the screen and then goes
away.
any suggestions?
Thanks
 
M

Mike

Hello
I have The following:
In my main file
<div id="txtHint"></div>
in my php file
echo "<p>$row_Recordset1</p>"
in my js
function stateChanged()
{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
// alert (xmlHttp.responseText)
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}

The element, which is correct, flashes on the screen and then goes
away.
any suggestions?
Thanks


I've got it down to the "onclick" in the form button.There seems to be
something that reloads the page, even with the meathod working
correctly. If I put the function in a onkeydown, everything works
fine. Anybody have experiance with this?
Thanks
Mike
 
M

Mike

Hello
I have The following:
In my main file
<div id="txtHint"></div>
in my php file
echo "<p>$row_Recordset1</p>"
in my js
function stateChanged()
{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
// alert (xmlHttp.responseText)
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
The element, which is correct, flashes on the screen and then goes
away.
any suggestions?
Thanks

I've got it down to the "onclick" in the form button.There seems to be
something that reloads the page, even with the meathod working
correctly. If I put the function in a onkeydown, everything works
fine. Anybody have experiance with this?
Thanks
Mike- Hide quoted text -

- Show quoted text -


Nevermind
 
K

Kailash Nadh

Hello
I have The following:
In my main file
<div id="txtHint"></div>
in my php file
echo "<p>$row_Recordset1</p>"
in my js
function stateChanged()
{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
// alert (xmlHttp.responseText)
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
The element, which is correct, flashes on the screen and then goes
away.
any suggestions?
Thanks

I've got it down to the "onclick" in the form button.There seems to be
something that reloads the page, even with the meathod working
correctly. If I put the function in a onkeydown, everything works
fine. Anybody have experiance with this?
Thanks
Mike


Apparently, your onclick executes first and the form gets submitted
anyway, hence reloading the page.
Try making the form button type 'button' and not 'submit' or try the
onsubmit event.
http://www.w3schools.com/jsref/jsref_onsubmit.asp

Kailash Nadh | http://kailashnadh.name
 
M

Mike

Hello
I have The following:
In my main file
<div id="txtHint"></div>
in my php file
echo "<p>$row_Recordset1</p>"
in my js
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
// alert (xmlHttp.responseText)
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
The element, which is correct, flashes on the screen and then goes
away.
any suggestions?
Thanks

I've got it down to the "onclick" in the form button.There seems to be
something that reloads the page, even with the meathod working
correctly. If I put the function in a onkeydown, everything works
fine. Anybody have experiance with this?
Thanks
Mike

Apparently, your onclick executes first and the form gets submitted
anyway, hence reloading the page.
Try making the form button type 'button' and not 'submit' or try the
onsubmit event.http://www.w3schools.com/jsref/jsref_onsubmit.asp

Kailash Nadh |http://kailashnadh.name- Hide quoted text -

- Show quoted text -


Thanks, thats what I ended up doing.Works fine now
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,382
Latest member
MichaleStr

Latest Threads

Top