JavaScript response check?

Started on the old forum in March 2013 · view the original in the archive · old links redirect here

10 replies · 961 views · started 13 years ago · 1 min read

4 participants
arnage Lead · 811 posts #1

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.

<script type="text/javascript" src="http://site.com/page/show_ads.js">
</script>
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
GumSlone Administrator Principal · 1,690 posts #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

External image (may be gone)

kevk3v Senior · 332 posts #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

arnage Lead · 811 posts #4

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

<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.

 $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. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
kevk3v Senior · 332 posts #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

arnage Lead · 811 posts #6

I don't have a clue about javascript and showing ads. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
kevk3v Senior · 332 posts #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

metulj Super moderator Principal · 1,726 posts #8

arnage wrote: I don't get you guys, this is all i have.

<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 ?

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ノ刀ノイリ!

Attachments: show_ads.zip
arnage Lead · 811 posts #9

I don't know is it gonna be readable for google ads then. Maybe even ban him... 🙁

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
GumSlone Administrator Principal · 1,690 posts #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

External image (may be gone)

arnage Lead · 811 posts #11

Ok, thanks for explanation. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close