Search code examples
javascriptajaxnode.jspebble-watch

Error when getting an AJAX request with Pebble.js


I have been doing an app for the pebble watch during the penn state hackathon. On campus I was getting the information from a local server(thats what i thought) using node.js and displaying that information on the watch. It worked perfect. Now, I am back at my home and for some reason the link for the http server changed, and now, when I get the ajax request (from this updated link) it fails, saying that the ajax request failed:null (null as the error I suppose) any ideas why??

The previous link that I was running was:http://client-75-102-97-252.mobility-up.psu.edu:3000

Now I am running on:http://Kevin-Cs-MacBook-Pro-2.local:3000

And it doesn't work.

I am using the ajax function as described in the Pebble.js API

ajax(
{
    url: 'http://Kevin-Cs-MacBook-Pro-2.local:3000/Kevin/medicine',

    type: 'json'
  },

  function(data, status, request) {
    console.log('Quote of the day is: ' + data.contents.medicine);
  },

  function(error, status, request) {
    console.log('The ajax request failed: ' + error);
  }
);

I’m not sure what is happening. Thanks, Kevin


Solution

  • The problem was with cloud pebble because it wasn't getting anything from the server, apparently it interfered. I downloaded the Pebble SDK, ran it locally and it worked