Results 1 to 8 of 8

Thread: Ajax problem

  1. #1
    Join Date
    Oct 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax problem

    1) Script Title:
    Basic Ajax Routine (get & Post)
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...jaxroutine.htm
    3) Describe problem:

    When I follow the example code:
    <head>
    //Step 1: Install the routine script:
    <script src="text/javascript" src="ajaxroutine.js">
    //CREDIT NOTICE GOES HERE
    </script>
    </head>

    <body>

    <script type="text/javascript">
    //Step 2: Define a "callback" function to process the data returned by the Ajax request:
    function processGetPost(){
    var myajax=ajaxpack.ajaxobj
    var myfiletype=ajaxpack.filetype
    if (myajax.readyState == 4){ //if request of file completed
    if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
    if (myfiletype=="txt")
    alert(myajax.responseText)
    else
    alert(myajax.responseXML)
    }
    }
    }

    //Step 3: Invoke the Ajax routine method to make the desired Ajax request.
    ajaxpack.getAjaxRequest("example.htm", "", processGetPost, "txt")
    </script>


    all I get is a blank page:

    http://testingsite.prose-n-poetry.com/scripts/test.htm
    Last edited by Usagi; 10-11-2007 at 02:43 AM.

  2. #2
    Join Date
    Oct 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I found the error:

    <!--Step 1: Install the routine script: -->
    <script src="text/javascript" src="/javascripts/ajaxroutine.js">

    it should be:
    <script type="text/javascript" src="/javascripts/ajaxroutine.js">

    This is an error on the DD page.

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Basic Ajax and IE6 (SP1) Problem?

    Was searching for some help and thought i would add to this thread as its sort of relevant...

    Ive been using the basic ajax routine from DD, like the one listed above by Usagi.

    Its has been working fine. However, ive noticed a problem that only seems to occur in IE6 (SP1).

    I use the 'ajaxpack.postAjaxRequest()' routine to send a form to an asp (vbscript) page, which then sends back a reply, depending on the reply, a certain action will be taken.

    In IE6 sp2, IE 7, firefox etc, the reply comes back fine.
    In IE6 SP1 on the first message gets through. All subsequent messages dont seem to send.
    The ajaxpack.postAjaxRequest seems to send, but the asp message never gets the request. Server logs show that the asp page is not being called. So where is the request going??

    And it only happens in IE6 SP2!! All other browsers work fine.

    On the processmessage() function, the myajax.readyState never seems to get to 4 (completed), and by the time is does, 2mins or so have passed. By this time, the myajax.status is way greater than 200 and so the response does not get processed.

    Any help appreciated.
    Last edited by jason_rmh; 10-18-2007 at 03:46 PM.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sounds like a caching issue. Inside ajaxroutine.js, try setting the below var to 1:

    Code:
    ajaxpack.addrandomnumber=1 //Set to 1 or 0. See documentation.
    p.s: In the future, please start a new thread when asking your own question, even if it's regarding the same script as another thread's.

  5. #5
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    Quote Originally Posted by ddadmin View Post
    Sounds like a caching issue. Inside ajaxroutine.js, try setting the below var to 1:

    Code:
    ajaxpack.addrandomnumber=1 //Set to 1 or 0. See documentation.
    p.s: In the future, please start a new thread when asking your own question, even if it's regarding the same script as another thread's.
    Hi,
    thanks for ya reply.
    This change made no difference to the problem.
    Any ideas welcome, im at my wits end with this

    Thanks

  6. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please post a link to the page on your site that contains the problematic script so we can check it out.

  7. #7
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking [Problem Solved]

    Solved the problem. Hope this will help someone else...
    After painfully investigating each bit of code (2.5 days so far), i realised that the POST was causing the problem.
    So i changed from POST to GET
    Code:
    var poststr=createpoststring()
    if (poststr != "")
    {
        ajaxpack.postAjaxRequest("example.htm", poststr, processGetPost, "txt")
    }
    to
    Code:
    var poststr=createpoststring()
    if (poststr != "")
    {
        ajaxpack.getAjaxRequest("example.htm", poststr, processGetPost, "txt")
    }
    Solving the problem. Although i am sending data from a form, it is not a huge amount in data terms, and have tested it with upto 1000chrs, which is plenty for my purpose.

    I am unsure what the POST is causing problems, but its not a problem for me to use GET, i realise this may not be an option in certain implementations.


    Thanks
    Jason

  8. #8
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Thanks for the update.

Bookmarks

Posting Permissions

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