display database values from ajax on a js pop up
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: display database values from ajax on a js pop up

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    160

    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

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,840

    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.

  3. #3
    Join Date
    May 2009
    Posts
    160

    Re: display database values from ajax on a js pop up

    Quote Originally Posted by PeejAvery View Post
    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......

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,840

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center