Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

How do I get this javascript web page to work? What am I missing?

Can't seem to get the attached webpage to work.

pinger.html
mystyle.css

Created this based upon the code at http://jsfiddle.net/GSSCD/2459/

I added tags and styles and script src, but can't seem to get working. I must be missing something simple.

Thanks for your help.

Rick Lindberg
0
Rick_Lindberg
Asked:
Rick_Lindberg
  • 9
  • 5
2 Solutions
 
HainKurtSr. System AnalystCommented:
it is working fine (i guess)
i see this:

localhost responded
google.com responded
ws-bdimperio8 timeout
ws-bdimperio8.payformance.net timeout
ws-bdimperio8.payformance.com responded
ws-bdimperio8.payspan.com responded
ws-bdimperio8/favicon.ico timeout
127.0.0.1 responded
unknown timeout

Open in new window

0
 
Rick_LindbergAuthor Commented:
That is what I should see, but when I run it from my desktop. I only get
 
tester

Open in new window

So I must be missing something in how my machine runs javascript.... hmmmm

I am running Foxpro.

Tried opening html file with  IE and then chrome but got the same result.

I am still missing something.
0
 
HainKurtSr. System AnalystCommented:
knockout-min.js cannot be downloaded or run locally... i may be doing something harmful :) activex permissions missing maybe...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
HainKurtSr. System AnalystCommented:
0
 
HainKurtSr. System AnalystCommented:
try saving this file to local, maybe it makes any difference...
0
 
HainKurtSr. System AnalystCommented:
yup, working fine :)
copy that file to same location with your html, update link and good to go

<script type='text/javascript' src='knockout-min.js'></script>

added to my library for potential future use...
0
 
Rick_LindbergAuthor Commented:
modified the <script> tag line as you suggested
webcode.PNG
with the following files in the directory
Files-in-Development-Directory.png
And I still get this:
NotWorking.PNG
0
 
HainKurtSr. System AnalystCommented:
wait a bit (like 30 sec) they will be showing up eventually...
unless you have something wrong in your file (syntax error)
install fiddler and check whats is happening after loading page (check requests)
also press f12 and check for any js errors...

running on ie (local)
0
 
HainKurtSr. System AnalystCommented:
if it helps, here what i have:

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Ping a server in javascript - jsFiddle demo</title>
  <script type='text/javascript' src='knockout-min.js'></script>
  <link rel="stylesheet" type="text/css" href="//jsfiddle.net/css/result-light.css">

  <style type='text/css'>
    .responded {
    color:green;
}
.checking, .unchecked {
    color:#FF8C00;
}
.timeout {
    color:red;
}
	</style>

<script type='text/javascript'>//<![CDATA[ 
window.onload=function(){
function ping(ip, callback) {

    if (!this.inUse) {
        this.status = 'unchecked';
        this.inUse = true;
        this.callback = callback;
        this.ip = ip;
        var _that = this;
        this.img = new Image();
        this.img.onload = function () {
            _that.inUse = false;
            _that.callback('responded');

        };
        this.img.onerror = function (e) {
            if (_that.inUse) {
                _that.inUse = false;
                _that.callback('responded', e);
            }

        };
        this.start = new Date().getTime();
        this.img.src = "http://" + ip + "/?now=" + this.start; 
        this.timer = setTimeout(function () {
            if (_that.inUse) {
                _that.inUse = false;
                _that.callback('timeout');
            }
        }, 1500);
    }
}
var PingModel = function (servers) {
    var self = this;
    var myServers = [];
    ko.utils.arrayForEach(servers, function (location) {
        myServers.push({
            name: location,
            status: ko.observable('unchecked')
        });
    });
    self.servers = ko.observableArray(myServers);
    ko.utils.arrayForEach(self.servers(), function (s) {
        s.status('checking');
        new ping(s.name, function (status, e) {
            s.status(status);
        });
    });
};
var komodel = new PingModel(['localhost',
    'google.com',
    'ws-bdimperio8',
    'ws-bdimperio8.payformance.net',
    'ws-bdimperio8.payformance.com',
    'ws-bdimperio8.payspan.com',
    'ws-bdimperio8/favicon.ico',
    '127.0.0.1',
    'unknown']);
ko.applyBindings(komodel);
}//]]>  

</script>

</head>
<body>
  <ul data-bind="foreach:servers">
    <li> <a href="#" data-bind="text:name,attr:{href: 'http://'+name}">tester</a>  <span data-bind="text:status,css:status"></span></li>
</ul>
  
</body>
</html>

Open in new window

0
 
Rick_LindbergAuthor Commented:
did you copy the ping.html from the jsfiddle site. could you post your ping.html file here?

Thanks for all your help,  sorry that I'm not getting there yet.
0
 
Rick_LindbergAuthor Commented:
looks like I was missing the

//<![CDATA[
window.onload=function(){

..... remainder of javascript.....

}//]]>

That did it!!!

Did you copy that script directly from the http://jsfiddle.net/GSSCD/2459/ site?  I couldn't figure out how to do that.
0
 
HainKurtSr. System AnalystCommented:
yes copied from your jsfiddle :)

using chome, right click, view frame source...
0
 
HainKurtSr. System AnalystCommented:
I don't think this is issue

//<![CDATA[
//]]>

but a missing "}" is...
0
 
Rick_LindbergAuthor Commented:
Hain thanks for your help

-Rick
0
 
Dave BaldwinFixer of ProblemsCommented:
I tried the original page which didn't work and then HainKurt's version which did work.  I copied different items from HainKurt's back to the original and the modified original started working when I copied the "window.onload=function(){".  I went back and commented it out and I got the original error again so I'm pretty sure that was the issue.  Some things were happening before the page was displayed.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 9
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now