-
June 5th, 2009, 12:46 PM
#1
display database values from ajax on a js pop up
how do i display database value from ajax on a javascript pop up. i am able to display it in an alert box or in a static location on the web page but i wish to display it on a pop up on the screen, which can be read and closed.
below is my code
Code:
var xmlhttp;
function showUser(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="get_user.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);
//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}// JavaScript Document
-
June 10th, 2009, 07:22 AM
#2
Re: display database values from ajax on a js pop up
For that, you can just create a div with CSS position set to absolute. After that, just play with the coordinates.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 15th, 2009, 12:39 PM
#3
Re: display database values from ajax on a js pop up
Originally Posted by PeejAvery
For that, you can just create a div with CSS position set to absolute. After that, just play with the coordinates.
hey thanks, i got that... now my last hurdle is i do display it exactly like how i wanted it using the below code
[code]
style="position:absolute; top:50; z-index:99; border:2px black solid; background-color:#99FFCC;"[\code]
NOW HOW DO I GET A CROSS OR CLOSE BUTTON OR HOW CAN I PUT IN SOME IMAGE SO THAT WHEN THEY CLICK ON THAT THIS POP UP DIV DISAPPEARS......
-
June 15th, 2009, 01:24 PM
#4
Re: display database values from ajax on a js pop up
You would do the same thing with the <img> or <a> tag and then make it fire a JavaScript function that hides the other <div> by altering the display property to none.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|