JavaScript response check?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    JavaScript response check?

    Is there any way to check is script getting any response from url source and if there isn't any, not to show anything?
    The problem is that when there isn't any, the script is forcing custom 404 error page to download.
    This is all whats in question, its about ads.

    Code:
    <script type="text/javascript" src="http://site.com/page/show_ads.js">
    </script>
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    #2
    in the show_ads.js
    define a variable, ie, var response = 1;

    and in the page where you load the show_ads.js put:
    if (typeof( response ) !== 'undefined')
    {
    //do something
    }
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      Jquery way

      $.ajax({
      url:'http://site.com/page/show_ads.js',
      type:'HEAD',
      error: function()
      {
      //file not exists
      },
      success: function()
      {
      //file exists
      }
      });
      Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

      Comment


        #4
        I don't get you guys, this is all i have.

        Code:
        <script type="text/javascript"><!--
        google_ad_client = "SomeNumbers";
        google_ad_slot = "SomeNumbers";
        google_ad_width = 728;
        google_ad_height = 90;
        //-->
        </script>
        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
        I don't have access to script show_ads.js.

        -----------

        And if i do something like this is it legal? Are they gonna ban this client? Its my friends site so i have to be careful.

        PHP Code:
         $response implode(''file('http://pagead2.googlesyndication.com/pagead/show_ads.js'));

         if (!empty(
        $response)) {

         echo 
        '<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>';

         } 
        Is it gonna work at all?

        ---------------

        It doesn't.
        Last edited by arnage; 04.03.13, 22:43.
        <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

        Comment


          #5
          Well then GumSlone gave a good solution

          Try

          if(typeof a.google_allow_expandable_ads != 'undefined')
          {
          alert('Response successful');
          }

          Google will always give a response for that js file, and if you see blank ads, you have to wait, you have the correct code.
          Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

          Comment


            #6
            I don't have a clue about javascript and showing ads.
            <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

            Comment


              #7
              I didn't either lol, but jquery is forcing me to learn it and its really easy so far
              Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

              Comment


                #8
                Originally posted by arnage View Post
                I don't get you guys, this is all i have.

                Code:
                <script type="text/javascript"><!--
                google_ad_client = "SomeNumbers";
                google_ad_slot = "SomeNumbers";
                google_ad_width = 728;
                google_ad_height = 90;
                //-->
                </script>
                <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                </script>
                I don't have access to script show_ads.js.

                -----------
                .....................
                will it help if you have ...//show_ads.js saved localy ?
                Attached Files
                Last edited by metulj; 04.03.13, 23:27.
                It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt.
                ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ !
                ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.
                キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

                Comment


                  #9
                  I don't know is it gonna be readable for google ads then. Maybe even ban him...
                  <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                  Comment


                    #10
                    for google ads leave the ads the way they are with the 404 error, after some time there will appear some ads, i guess that google needs some time to collect informations about the page where the ads are placed to show its keyword targeted ads there.
                    Advertise your mobile site for FREE with AdTwirl

                    Comment


                      #11
                      Ok, thanks for explanation.
                      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                      Comment

                      Working...
                      X