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 3 of 3
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Might be simple, might not

    I discovered Ajax a couple weeks ago and so far I'm impressed. I've been writing my own library and it seems to be working out well for me. My server side programs return an xml document and my client-side javascript parses that and takes appropriate actions. Working great so far.

    I think this is pretty typical... the set up could be depicted as follows:
    step 1.1 (client) ajax call using GET method -----> (server)
    step 1.2 (client) <------------------- xml response (server)

    As we all know, Ajax won't submit a file. So I'm going the regular form submission/response goes to hidden iframe strategy. I've written a routine that accepts the uploaded file and sends back a small html document with an onload() event to kick off the ajax submit. This currently looks like this:

    step 2.1 (client) form submit using POST method -----> (server)
    step 2.2 (client) <--- response via onload() in iframe (server)
    step 2.3 (client) ajax call using GET method --------> (server)
    step 2.4 (client) <---------------------- xml response (server)

    Now the problem... or rather... what I'd like to do... is use an xml response for step 2.2 rather than the small html document. Or maybe there is a way to wrap my xml reponse up in the small html document. My goal is to be able to utilize the same function I wrote (that handles steps 1.2 and 2.4) to handle step 2.2 as well.

    Any ideas?

    Thanks in advance,
    Darren

  • #2
    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
    My suggestion is look at what other libraries are doing to see how they work. Prototype.js is a good example.

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

  • #3
    New Coder
    Join Date
    May 2005
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ok, I found a way to kick off a function within an xml document. It just goes like this:

    <script type="text/javascript" src="/mylibrary.js"></script>
    <script type="text/javascript">
    //<![CDATA[
    myFunction();
    //]]>
    </script>

    Now I just need myFunction to be able to grab the whole contents of the frame it is on. I thought I could just do a document.body.innerHTML but I have discovered that innerHTML does not work with an XML document (doh!). I've been trying to find the JavaScript command that will give me what I'm after, but I'm not having any luck right now.

    Thanks in advance,
    Darren


  •  

    Posting Permissions

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