-
28 Jun 2012 9:19 AM #1
Answered: Can't parse a return string from JsonP!
Answered: Can't parse a return string from JsonP!
Hi guy,
I have made a request of JsonP, but the return string can't parse. I don't know why?
I'm using Sencha touch 2.0.1.1, webservice: attach file, browser: Safari: 5.1.7, OS: window 7.
This is my code (copy from JsonP example, but the url is my web service):
This is a error:Code:Ext.Viewport.add({ xtype: 'button', text: 'Make JsonP Request', centered: true, handler: function(button) { // Mask the viewport Ext.Viewport.mask(); // Remove the button button.destroy(); // Make the JsonP request Ext.data.JsonP.request({ url: 'http://localhost:7794/GetEmployees.svc/json/hello', callbackKey: 'callback', success: function(result, request) { // Unmask the viewport Ext.Viewport.unmask(); } }); } });
json-fail.jpg
json-fail-detail.jpg
What's a trouble? The string is a json string. But why it can't read it?
Please help me to solve it, thanks!
-
Best Answer Posted by mitchellsimoens
That's because your response is only JSON not JSONP. Sample JSONP is
Code:Ext.data.JsonP.callback01({"success": true});
-
28 Jun 2012 9:34 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
That's because your response is only JSON not JSONP. Sample JSONP is
Code:Ext.data.JsonP.callback01({"success": true});Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
28 Jun 2012 5:04 PM #3
jsonP string sample
jsonP string sample
Hi mitchellsimoens,
May you share me a sample jsonP string? It's so good if there is a sample of web service that return a jsonP string.
I have tried to return a string like:
Code:{"helloResult":"Ext.data.JsonP.callback1({sucess:true})"}
But it's still not work.
Thanks so much
-
28 Jun 2012 11:02 PM #4
solved
solved
Hi, I have solved my trouble, we must config to WCF return the string in jsonP format.
Thanks.


Reply With Quote