During production the AJAX result from xmlHttp.responseText was not displayed.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eros
    New Member
    • Jun 2007
    • 66

    During production the AJAX result from xmlHttp.responseText was not displayed.

    During development (debugging) the site works well but when I release from the debugging and test into production.. All the AJAX was not performed.. the result from xmlHttp.respons eText was not displayed.

    I added an alert in order to check if the script was called. The alert was displayed.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by eros
    During development (debugging) the site works well but when I release from the debugging and test into production.. All the AJAX was not performed.. the result from xmlHttp.respons eText was not displayed.

    I added an alert in order to check if the script was called. The alert was displayed.
    If you sent some code then it would be better to point out your errors.
    So post the relevant code with proper code tag, the experts are here figure out your problems and as well as your solutions.

    Kind regards,
    Dmjpro.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, Eros.

      A mistake that I sometimes make is forgetting to change the URL of the AJAX request. For example, when I test on my development machine, I fetch data from localhost, but once the script goes live, I have to remember to use the address of the deployment server.

      As a sidenote, I once had an embarrassing faux pas on eBay. To save bandwidth, I used file:// URIs for all of my images in my auction description, but then I forgot to change them before I saved the description. Of course, it looked fine on my computer! I didn't notice until 2 hours before the auction ended! Oops :[

      Comment

      • eros
        New Member
        • Jun 2007
        • 66

        #4
        Javascript/AJAX code: ajax.js
        [CODE=javascript]var xmlHttp;
        var m_placeholder;

        function executeProcess( serverscriptfil e, placeholder, fieldcode, posts) {
        alert('ajax');
        // line of codes for confirmation messages.

        xmlHttp=GetXmlH ttpObject();
        if (xmlHttp==null)
        {
        alert ("Browser does not support HTTP Request");
        return;
        }
        m_placeholder = placeholder;
        var url=serverscrip tfile;
        xmlHttp.onready statechange=sta teChanged;
        xmlHttp.open("P OST", url, true);
        xmlHttp.setRequ estHeader('Cont ent-Type','applicat ion/x-www-form-urlencoded; charset=shift_j is');
        xmlHttp.send(po sts);
        }

        function stateChanged() {
        if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
        {
        document.getEle mentById(m_plac eholder).innerH TML=xmlHttp.res ponseText;
        }
        }

        function GetXmlHttpObjec t() {
        var xmlHttp=null;
        try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest( );
        }
        catch (e)
        {
        //Internet Explorer
        try
        {
        xmlHttp=new ActiveXObject(" Msxml2.XMLHTTP" );
        }
        catch (e)
        {
        xmlHttp=new ActiveXObject(" Microsoft.XMLHT TP");
        }
        }
        return xmlHttp;
        }[/CODE]

        HTML code to call the script:
        [CODE=html] <input id="kensaku" name="kensaku" type="button" value="検索" style="width: 49px; height: 33px"
        onclick="<?php echo "executeProcess ('processes/pro" . $_SESSION['window'] . "', '" . $_SESSION['placeholder'] ."', '". $_SESSION['fieldcode'] ."', ". $_SESSION['posts'] ."+'&rowsperpag e=5&pageidx=1&m ode=kensaku' )"; ?>" />[/CODE]

        PHP Code:
        [PHP]<?php
        header('Content-Type: text/html; charset=shift_j is');
        session_start() ;
        session_destroy (); // just need to reset my session vars
        session_start() ;
        $_SESSION['window'] = basename(__FILE __);
        $_SESSION['placeholder'] = 'table';
        $_SESSION['fieldcode'] = "shopcd";
        $_SESSION['posts'] = "'shopcd=' + shopcd.value"
        . "+'&shopnam e=' + shopname.value"
        . "+'&keitaimail= ' + keitaimail.valu e"
        . "+'&keitaibango u=' + keitaibangou.va lue"
        . "+'&email=' + email.value"
        . "+'&fax=' + fax.value"
        . "+'&shoppostcod e=' + shoppostcode.va lue"
        . "+'&choume= ' + choume.value"
        . "+'&banchi= ' + banchi.value"
        . "+'&ban=' + ban.value"
        . "+'&heyamei =' + heyamei.value";
        ?>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
        <html xmlns="http:?//www.w3.org/1999/xhtml" >
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=shift_j is">
        <title>配達システムペー ジ</title>

        <SCRIPT type="text/javascript" src="<?php echo WORKINGSCRIPTS; ?>ajax.js" >
        <!-- Beginning of JavaScript -

        // - End of JavaScript - -->
        </SCRIPT>

        </head>
        <body >
        </body>
        </html>[/PHP]

        WORKINGSCRIPTS constant variable holds the absolute location of the scripts usign webroot. (http://localhost/websites/delivery/scripts/ajax.js)
        kensaku means search.

        I'am using Zend Studio 5.0 for IDE.
        PHP5.2.3
        Apache2.2.4
        WINDOWS XP Japanese OS
        Last edited by pbmods; Aug 28 '07, 02:31 PM. Reason: Changed [CODE] to [CODE=javascript].

        Comment

        • eros
          New Member
          • Jun 2007
          • 66

          #5
          Originally posted by pbmods
          Heya, Eros.

          A mistake that I sometimes make is forgetting to change the URL of the AJAX request. For example, when I test on my development machine, I fetch data from localhost, but once the script goes live, I have to remember to use the address of the deployment server.

          As a sidenote, I once had an embarrassing faux pas on eBay. To save bandwidth, I used file:// URIs for all of my images in my auction description, but then I forgot to change them before I saved the description. Of course, it looked fine on my computer! I didn't notice until 2 hours before the auction ended! Oops :[
          My setup was. I am developing locally with my PC, webserver, php5 and tools are installed in my PC but the database is remotely connected to the database server.

          What do you think? There will be a problem on that settings?

          Additional:
          Even though I said it is in production.. I am still using the localhost (http://localhost/websites/delivery/index.php) to access and test my small web apps.

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Is shift_jis supported by your Browser?
            Try to make sure that.

            Kind regards,
            Dmpjro.

            Comment

            • eros
              New Member
              • Jun 2007
              • 66

              #7
              Originally posted by dmjpro
              Is shift_jis supported by your Browser?
              Try to make sure that.

              Kind regards,
              Dmpjro.
              Yes of course, I am using Mozilla Firefox, IE6, Opera9.

              The site is working well in debugging using Zend Studio IDE tool.

              Comment

              • dmjpro
                Top Contributor
                • Jan 2007
                • 2476

                #8
                Originally posted by eros
                function stateChanged() {
                if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
                {
                document.getEle mentById(m_plac eholder).innerH TML=xmlHttp.res ponseText;
                }
                }

                xmlHttp.readySt ate=="complete"
                What do you mean by that?
                And I think xmlHttp.readySt ate==4, it is enough whether the page loading completed successfully or not.
                And to check out the status code whether the page successfully loaded or not, you have to write ........
                xmlHttp.status= =200
                Make sure that.
                And what is your responseText?
                It prints nothing?

                Kind regards,
                Dmjpro.

                Comment

                • eros
                  New Member
                  • Jun 2007
                  • 66

                  #9
                  Originally posted by dmjpro
                  xmlHttp.readySt ate=="complete"
                  What do you mean by that?
                  And I think xmlHttp.readySt ate==4, it is enough whether the page loading completed successfully or not.
                  And to check out the status code whether the page successfully loaded or not, you have to write ........
                  xmlHttp.status= =200
                  Make sure that.
                  And what is your responseText?
                  It prints nothing?

                  Kind regards,
                  Dmjpro.
                  I removed the xmlHttp.readySt ate=="complete" condition. And it always return 200 for xmlHttp.status.

                  responseText returns nothing.

                  Comment

                  • dmjpro
                    Top Contributor
                    • Jan 2007
                    • 2476

                    #10
                    Originally posted by eros
                    I removed the xmlHttp.readySt ate=="complete" condition. And it always return 200 for xmlHttp.status.

                    responseText returns nothing.
                    Ok.
                    Now I am sure that your page successfully loaded with status code 200.
                    Now do one thing.
                    Try to run your target page with passing the parameters it needs separately and see what is the O/P it is showing.
                    If it is coming then there should not any problem with Response Text.
                    I hope so.

                    Kind regards,
                    Dmjpro.

                    Comment

                    • eros
                      New Member
                      • Jun 2007
                      • 66

                      #11
                      "Try to run your target page with passing the parameters it needs separately"
                      -> I will load the serverscriptfil e (target page) on by it self and provide the parameters needed by the target page? Not to be called in AJAX?

                      "see what is the O/P it is showing."
                      -> it means the Output?

                      Sorry not too familiar with the terminologies.

                      Comment

                      • dmjpro
                        Top Contributor
                        • Jan 2007
                        • 2476

                        #12
                        Originally posted by eros
                        "Try to run your target page with passing the parameters it needs separately"
                        -> I will load the serverscriptfil e (target page) on by it self and provide the parameters needed by the target page? Not to be called in AJAX?

                        "see what is the O/P it is showing."
                        -> it means the Output?

                        Sorry not too familiar with the terminologies.
                        Yes you are right.
                        Test to call the page with out using AJAX.
                        Just simply call it separately with required parameters.
                        And see what it shows on the browser means the HTML code.
                        Best of luck with your try.
                        And sorry for using bad code words.
                        I am really sorry.

                        Kind regards,
                        Dmjpro.

                        Comment

                        • eros
                          New Member
                          • Jun 2007
                          • 66

                          #13
                          Unfortunately it runs well when it is in debug mode but not in release mode......

                          test.php
                          Code:
                          <a href="proshops01test.php?mode=kensaku&shopname=ロズビン&rowsperpage=5&pageidx=1" >test</a>
                          Output: (please copy and paste the url if it is broken)
                          1) http://anime dot geocities dot jp/rozvinbm_jp/ajaxnotdisplaye d dot jpg

                          2) http://anime dot geocities dot jp/rozvinbm_jp/ajaxnotdisplaye d2 dot jpg


                          I realized not in responseText. Please tell me any hints on this.. on how to solve the problem.

                          Comment

                          • dmjpro
                            Top Contributor
                            • Jan 2007
                            • 2476

                            #14
                            Originally posted by eros
                            Unfortunately it runs well when it is in debug mode but not in release mode......

                            test.php
                            Code:
                            <a href="proshops01test.php?mode=kensaku&shopname=ロズビン&rowsperpage=5&pageidx=1" >test</a>
                            Output: (please copy and paste the url if it is broken)
                            1) http://anime dot geocities dot jp/rozvinbm_jp/ajaxnotdisplaye d dot jpg

                            2) http://anime dot geocities dot jp/rozvinbm_jp/ajaxnotdisplaye d2 dot jpg


                            I realized not in responseText. Please tell me any hints on this.. on how to solve the problem.
                            Look what I think if your page runs separately then it will run with AJAX also and your Response Text will also return some HTML code if it is about to show.
                            Try to varify again with all parameters you send in AJAX code.
                            Wish you a very best of luck with your try.

                            Kind regards,
                            Dmjpro.

                            Comment

                            • eros
                              New Member
                              • Jun 2007
                              • 66

                              #15
                              It will be ok? even the same case...same output?
                              I mean of the same case is regardless of using AJAX code... the problem still remains...

                              In Debug mode:
                              -> There's no any problem. With AJAX or with out AJAX (by itself only).

                              In Release mode: (not debugging)
                              -> The problem was still occuring regardless of using AJAX or not.

                              Maybe in between the PHP is the problem... I think in PHP.INI configurations. ...
                              What do you think?

                              Comment

                              Working...