This article is the study of their own in the process of learning Sencha touch record, mainly JSONP cross-domain request this aspect, for Wei he is cross-domain concept and unfamiliar, you can ask the mother.
First Picture:
I want to complete the function is the table drop-down refresh, and send the request to my own writing service terminal, because the service program and this Sencha program is no longer a domain, there is always a request error (the approximate information is a cross-domain problem). These two days is really tortured by this problem for a long time, because did not touch the Sencha touch Jsonp, began also confused, also read a lot of information. Finally understood the JSONP's request pattern in Sencha.
This is roughly what it means (see picture):
Look at the request URL, when requested in JSONP mode, Sencha will automatically generate a CALLBACK=EXT.DATA.JSONP.CALLBACK3 parameter, this is a callback, other you do not care, as long as the server to return a similar
Ext.data.JsonP.callback2 ([{"Name": "Li Yang 1", "Age": "$", "Potourl": "http://img5.duitang.com/uploads/item/201408/05/ 20140805170730_b5cza.jpeg "}]), the returned type should be text/javascript, that is, the method body of a JavaScript is returned, so that when the request is complete, The server returns the result and is automatically injected into the callback in the form of a script to execute. That's all I can understand.
The following can be affixed to the server code: I am using the ASP. NET Web API Services
[HttpGet] Public Httpresponsemessage getallcontacts (string _dc,string page,string Start, String limit,string callback)// Data method supported in JSONP format { person[] Persons = new person[] { new person () {Name = "Li Yang 1", age = "$", potourl= "http:/" /img5.duitang.com/uploads/item/201408/05/20140805170730_b5cza.jpeg "} }; String content = String. Format ("{0} ({1})", Callback, Jsonconvert.serializeobject (Persons)); var response= request.createresponse (Httpstatuscode.ok, content); Response. Content = new Stringcontent (content, Encoding.UTF8, "Text/javascript"); return response; }
Study on the JSONP cross-domain request of Sencha Touch