PDA

View Full Version : Please Help Newbie Question :(



bydamien
16 Aug 2011, 3:30 PM
i am very new this amazing Touch components 7 days i just read and test someting in my test project

but i couldn't success to read data please someone light me about some problems :(
thank you for all

here is my codes


Ext.regModel('Categories', { fields : [ {
name : 'MasterID',
type : 'string'
}, {
name : 'Tanim',
type : 'string'
} ]
});


BurakApp.stores.Categories = new Ext.data.Store({ model : 'Categories',
proxy : {
type : 'ajax',
url : 'http://update.syssoft.ro/Deneme.ashx?C=Categories',
reader : {
type : 'json',
root : 'results'
}
},
autoLoad : true
});

this my web service return data


{"vw_touch_kategorler":[{"MasterID":1,"Tanim":"GUSTARI"},{"MasterID":2,"Tanim":"SALATE"},{"MasterID":3,"Tanim":"CIORBE"},{"MasterID":4,"Tanim":"MANCARE GATITA"},{"MasterID":5,"Tanim":"FIRIN"},{"MasterID":6,"Tanim":"GRATAR"},{"MasterID":7,"Tanim":"BAUTIRI"},{"MasterID":8,"Tanim":"DESERTURI"},{"MasterID":9,"Tanim":"ALTE"}]}

and this error messages i get


XMLHttpRequest cannot load http://update.syssoft.ro/Deneme.ashx?C=Categories&_dc=1313537210274&limit=25. Origin null is not allowed by Access-Control-Allow-Origin.


7212 (file:///C:/Users/bydamien/Documents/Visual%20Studio%202010/Projects/SenchaTest/SenchaTest/touch/sencha-touch-debug.js)
Uncaught TypeError: Cannot read property 'length' of undefined

please help me to understand :(
thanks again

lylepratt
16 Aug 2011, 6:41 PM
You need to look into "scripttag" proxy (or jsonp). You can not make cross side requests with standard Ajax calls. That is why you are receiving the error.

bydamien
16 Aug 2011, 11:40 PM
hello lylepratt

thanks for the answer, could you show me how do i use scripttag or jsonp because i read alot of topic and right now all i am so mixed everything please help me on this my code how to fix this problem

thanks again

epiphanydigital
17 Aug 2011, 6:46 AM
YourApp.SomeStore = new Ext.data.Store({
model : 'modelId',
proxy : {
type : 'scripttag',
url : 'http://somedomain.com/somejsonresponse.json',
reader : new Ext.data.JsonReader({
root : 'someRoot',
record : 'someRecord'
})
}
});

bydamien
17 Aug 2011, 10:11 AM
now this error i am getting

27540

and this warning

1 (http://update.syssoft.ro/Deneme.ashx?C=Categories&_dc=1313603584557&limit=25&callback=stcCallback1001)
Resource interpreted as Script but transferred with MIME type application/json.


thanks again

lylepratt
17 Aug 2011, 10:14 AM
You data source needs to specifically support JSONP. It will not work with just a normal JSON feed.

Basically, the JSON data needs to be wrapped in a function.

You should read this to get a good understanding of what a scripttag proxy using JSONP really is:
http://en.wikipedia.org/wiki/JSONP

bydamien
17 Aug 2011, 10:44 AM
hello again lylepratt

i am using this vb.net code for the convert sql data json maybe i have problem here


If ctx.Request.QueryString("C") = "Categories" Then Dim sqlConn As SqlConnection = New SqlConnection("Server=127.0.0.1,1433;Database=KonakDB2011;User ID=sa;Password=aacc;")
sqlConn.Open()
Dim sqlComm As SqlCommand = New SqlCommand()
sqlComm.Connection = sqlConn
sqlComm.CommandText = "SELECT [MasterID], [Tanim] FROM vw_touch_kategorler;"
Dim sqlDataAdapt As SqlDataAdapter = New SqlDataAdapter(sqlComm)
Dim ds As DataSet = New DataSet
sqlDataAdapt.Fill(ds)
sqlDataAdapt.Dispose() : sqlComm.Dispose() : sqlConn.Close() : sqlConn.Dispose()
ds.DataSetName = "Data"
ds.Tables(0).TableName = "vw_touch_kategorler"
Dim JsonResult As String = Newtonsoft.Json.JsonConvert.SerializeObject(ds)
ctx.Response.ContentType = "application/json"
ctx.Response.Write(JsonResult)
End If

couldn't found worked sample about json data just this i made if you have any sample to make good jsonp please share with me then i can try understand and will fix problem

thanks a lot your helps

bydamien
17 Aug 2011, 12:35 PM
i solve the problem.. just i add my service code this code




Dim cb As [String] = ctx.Request.Params.[Get]("callback")
Dim responseString As [String] = ""
If Not [String].IsNullOrEmpty(cb) Then
responseString = cb & "(" & JsonResult & ")"
Else
responseString = JsonResult
End If
ctx.Response.Write(responseString)


thanks for helps..

referans helps
http://dev.sencha.com/deploy/touch/docs/?class=Ext.data.ScriptTagProxy

epiphanydigital
23 Aug 2011, 6:39 AM
That's a server side issue, and won't cause any real problems. I wouldn't worry about it, but if you are still concerned you can change the delivery method for that file type in your Apache or IIS configuration.