setInterval and errors
Unable to call setInterval cross-domain
by shelbyz
HTML
<body>
<p id="ddd">Stuff here</p>
</body
CSS
table th { text-align:left; padding-right: 3em; font-style:italic }body { font-family: Helvetica, Arial }
input:not([type]), input[type=text], input[type=password], select { background-color: #FFFFCC; border: 1px solid gray; padding: 2px; }
JavaScript
//debugger;
// jQuery UI Widget definition
(function ($) {
$.widget("ui.NetFlix", {
options: {
// figure out if any options would be needed...
},
_create: function () {
// remember this instance
},
_init: function () {
this.render();
},
render: function () {
// figure out the styling we want here and append it...
this.element.append("<p>Inserted Widget Data</p>");
success = function(result) {
alert("Movie count: " + result["d"]["results"].length);
};
getCat = function () {
jQuery.support.cors = true;
$.ajax({
url: "http://odata.netflix.com/v2/Catalog/Titles?$select=Name,Runtime,ReleaseYear&$filter=substringof('" + "cat" + "',Name)&$orderby=Name&$format=json",
//url: "http://odata.netflix.com/v2/Catalog/Titles?$select=Name,Runtime,ReleaseYear&$filter=substringof('" + "cat" + "',Name)&$orderby=Name&$callback=?&$format=json",
type: "GET",
//dataType: "jsonp",
success: success,
error: function (XHR, textStatus, errorThrown) {
alert(textStatus + ":" + errorThrown);
}
});
};
setInterval("getCat()", 15000);
return this;
},
destroy: function () {
// call the original destroy method since we overwrote it
//$.Widget.prototype.destroy.call(this);
}
});
})(jQuery);
$("#ddd").NetFlix();