-
1 May 2012 3:20 AM #1
Unanswered: Invalid JSON primitive in Sencha 2.0 - Working in 1.0
Unanswered: Invalid JSON primitive in Sencha 2.0 - Working in 1.0
I am getting an "Invalid JSON primitive" error after moving to Sencha 2.0, and can't get it to work.
The JS code is this:
The ASP.NET code is this:Code:Ext.regModel('TemplateList', { fields: ['TemplateID', 'StateID', 'Caption', 'Subject', 'ForwardToType', 'ForwardTo', 'DND', 'StateEndingType', 'TextIsRequired', 'DetailsRequired', 'SuggestedEndTime'] }); var myTemplateListXTemplate = new Ext.XTemplate('<div>' + '<div class="TemplateStateEndingType{DetailsRequired}">{Caption}</div>' + '</div>'); myTemplateStore = new Ext.data.Store({ model: 'TemplateList', storeID: 'myTemplateStore', autoLoad: true, proxy: { headers: { 'Content-Type': 'application/json; charset=utf-8' }, url: 'Ajax.aspx/GetTemplateList', type: 'ajax', limitParam: null, actionMethods: { read: 'POST' }, reader: { type: 'json', root: 'd' } } });
How do I get this to work in Sencha 2.0? I've read the documentation and tried various changes, but I can't get it to work.Code:[WebMethod()] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] static public AjaxTVTemplate[] GetTemplateList() { ... }
-
3 May 2012 4:36 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,617
- Vote Rating
- 435
- Answers
- 3102
What does the JSON look like?
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.
-
3 May 2012 4:40 AM #3
Not sure - it's genereated in ASP.NET. It worked with Sencha 1.
Now it doesn't look like the function is even executed. It does not show up in the browser debugger.
-
3 May 2012 4:51 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,617
- Vote Rating
- 435
- Answers
- 3102
You checked in the Network tab in dev tools?
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.
-
3 May 2012 4:57 AM #5
Yes that is where I got the error message. This is more information:
HEADER INFORMATION
Request URL:http://localhost:53478/iPhone/Ajax.a...=1336049668004
Request Method:POST
Status Code:500 Internal Server Error
Request Headers
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:14
Content-Type:application/json;charset=UTF-8
Cookie:ASP.NET_SessionId=33at3f3y41lgfdyacm5h4e1e; .ASPXAUTH=C0398D7A8070CB9E9805F57ADCC8C446F6DA729D56B4D6137E4B4C8DB1A92768610E1E47D86BBF7ADDCF30822810DCF80366A3597907DCCF9399F468A7E31063CF0091C18D2270776BF71DBB0A29A2A28E5E51520BBE6DCBC9F80FF62F9B05016DF1A680A4EB7E201BD9F269D5955C427ADA9DABEE8D51D8C99931B95AEB0A3223E09F8967F64786004543EDC219CDEE7136470C52C4632B5644A2D4C9B3B2B918A6FA6D; Edition=Basic
Host:localhost:53478
Origin:http://localhost:53478
Referer:http://localhost:53478/iPhone/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.10 (KHTML, like Gecko) Chrome/20.0.1123.1 Safari/536.10
X-Requested-With:XMLHttpRequest
Query String Parameters
_dc:1336049668004
Request Payload
page=1&start=0
Response Headers
Cache-Control:private
Connection:Close
Content-Length:1062
Content-Type:application/json; charset=utf-8
Date:Thu, 03 May 2012 12:54:28 GMT
Server:ASP.NET Development Server/10.0.0.0
X-AspNet-Version:2.0.50727
jsonerror:true
RESPONSE
{"Message":"Invalid JSON primitive: page.","StackTrace":" at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}
When I enable the Visual Studio debugger, I can see that it never enters the GetTemplateList in AJAX.ASPX function. So somehow it's not finding the function as it used to in Sencha 1.
-
3 May 2012 5:15 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,617
- Vote Rating
- 435
- Answers
- 3102
So it's returning that in the JSON... That would tell me that error is happening on the server
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.
-
3 May 2012 5:22 AM #7
Yes, somehow the Sencha request is not reaching the correct function, as it did before. So there is some Sencha setting that I am missing.
-
3 May 2012 5:36 AM #8Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,617
- Vote Rating
- 435
- Answers
- 3102
Compare the requests between ST1's and ST2's. What's different? Different URL? Different params?
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.
-
3 May 2012 5:37 AM #9
Yes, good idea. I will try to compare the two and see what is different.
Will get back to you
Thanks
-
3 May 2012 6:29 AM #10
I have tried this, and one thing I notice is different is that in Sencha 2, I have this in the header:
Request Payload
page=1&start=0
This is not part of the header in Sencha 1. How can I remove this? And what is this?


Reply With Quote