PDA

View Full Version : JSONP Problem



fgeorge
7 Dec 2010, 12:32 PM
Hello,

i wrote some code to try and consume an ASP.NET MVC Feed but i get a blank page.

Any ideas?


Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
layout: 'card',
indicator: false,
onReady: function() {
var postPanel = new Ext.Panel({
fullscreen: true,
scroll: 'vertical',
tpl: new Ext.XTemplate([
'<h2>{gainers}<small> on {Open}</small></h2>',
'<p>{Close}</p>'
]);
});

Ext.getBody().mask(false, '<div class="demos-loading">Loading&hellip;</div>');

Ext.util.JSONP.request({
url: 'mdata.taviatech.com.ng/mobiledb/topgainers',
callbackKey: 'callback',
callback: function(result) {
var blogpost = result.data.blogpost;
if (blogpost) {
postPanel.update(blogpost);
postPanel.scroller.scrollTo({x: 0, y: 0});
}
else {
alert('There was an error retrieving the NSE Data.');
}
Ext.getBody().unmask();
}
});
}
});

The JSONP URL is in the code snippet above so you can test it on your own.

Thanks

mrsunshine
7 Dec 2010, 12:53 PM
you have a Syntx error in you code,
there is a ; to much it should be


tpl: new Ext.XTemplate([
'<h2>{gainers}<small> on {Open}</small></h2>',
'<p>{Close}</p>'
])

use jslint (http://jslint.com/) to check that you have valid source code.

take a look to your browsers networkpanel the request thows an 404 error.
you have to add the protocol to the url


url: 'http://mdata.taviatech.com.ng/mobiledb/topgainers',



hope that helps to get on the right way

fgeorge
8 Dec 2010, 7:14 AM
Thanks for your reply... i use jslint.com to validate the code and i get the following error;

Error:
Implied global: Ext 2,10,13,19,21,33, alert 31

i'm not too strong in javascript and i would really like to know what the problem is.

The code i used is below;


Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
layout: 'card',
indicator: false,
onReady: function() {
var postPanel = new Ext.Panel({
fullscreen: true,
scroll: 'vertical',
tpl: new Ext.XTemplate([
'<h2>{gainers}<small> on {Open}</small></h2>',
'<p>{Close}</p>'
])
});

Ext.getBody().mask(false, '<div class="demos-loading">Loading&hellip;</div>');

Ext.util.JSONP.request({
url: 'http://mdata.taviatech.com.ng/mobiledb/topgainers',
callbackKey: 'callback',
callback: function(result) {
var blogpost = result.data.blogpost;
if (blogpost) {
postPanel.update(blogpost);
postPanel.scroller.scrollTo({x: 0, y: 0});
}
else {
alert('There was an error retrieving the NSE Data.');
}
Ext.getBody().unmask();
}
});
}
});