Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Asp Xml Ajax

  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Asp Xml Ajax

    Hi,

    I have a simple bloging/comments system that has a form - this form then uses an xmlHttp request, where my asp file extracts data from my database and creates an xml form.

    However Im having problems controlling the output of the database. I want it to display everything with is does according to the SQL query. however i might want to display certain things in different ways e.g. bold italic etc.

    However it just displays it in one big set and i can touch any of the data.

    what am i doing wrong? and what do i need to be looking into?? thanks

    stevanicus

    AJAX
    Code:
    function blog()
    {
    var xmlDoc=xmlHttp.responseXML.documentElement;
    document.getElementById("tBlog").innerHTML=xmlHttp.responseText;
    document.getElementById("bgId").innerHTML=
    xmlDoc.getElementsByTagName("blogId")[0].childNodes[0].nodeValue;
    document.getElementById("bgbody").innerHTML=
    xmlDoc.getElementsByTagName("blogBody")[0].childNodes[0].nodeValue;
    document.getElementById("bgmadeBy").innerHTML=
    xmlDoc.getElementsByTagName("blogAuthor")[0].childNodes[0].nodeValue;
    }
    HTML
    Code:
    <div id="tBlog">
    <b><span id="bgId"></span></b><br />
    <span id="bgbody"></span><br />
    <span id="bgmadeBy"></span>
    </div>

    thanks again
    Last edited by stevanicus; 12-27-2007 at 12:45 PM.

  • #2
    New Coder
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    If it isXML, you need to use responseXML and loop through the nodes to get out the data.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #4
    New Coder
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,

    i tried that, but then it displays the last record in the xml document.

  • #5
    New Coder
    Join Date
    Dec 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this is what i added
    Code:
    var xmlDoc=xmlHttp.responseXML.documentElement;
    	for (i=0; i<=3; i++)
    	{
    		document.getElementById("bgId").innerHTML = xmlDoc.getElementsByTagName("blogId")[i].childNodes[0].nodeValue;
    		document.getElementById("bgbody").innerHTML =xmlDoc.getElementsByTagName("blogBody")[i].childNodes[0].nodeValue;
    		document.getElementById("bgmadeBy").innerHTML = xmlDoc.getElementsByTagName("blogAuthor")[i].childNodes[0].nodeValue;
    	}
    it then it only displays the last record... i know why, but i dont know how to get it so it doesnt replace the old record just adds it to the bottom of it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •