Hi,
I created a json using WCF . my link in browser
"http://localhost:52849/restfullservice/Service1.svc" shows
You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
http:
You can also access the service description as a single file:
http:
and
http:
[{"Id":1,"Name":"xyz","Dept":"development ","Email":"xyz@gmail.com","Mobile":638719362},{"Id":2,"Name":"abc","Dept":"development
,"Email":"abc@gmail.com","Mobile":638719318},{"Id":3,"Name":"aaa","Dept":"testing ","Email":"aaa@gmail.com","Mobile":638763361},
{"Id":4,"Name":"fff","Dept":"development ","Email":"aaa@gmail.com","Mobile":638261953}]
i want to parse this json in my mobile app using titanium
app.js:
var win1 = Titanium.UI.createWindow({
backgroundColor:'white'
});
var url="http://localhost:52849/restfullservice/Service1.svc/getdetails";
var table = Ti.UI.createTableView();
var tabledata=[];
var json,row,i,idLabel,nameLabel,deptLabel,emailLabel,mobileLabel,id,name,dept,email,mobile;
var xhr=Ti.Network.createHTTPClient({
onload:function(){
json=JSON.parse(this.responseText);
for(i=0;i<json.length;i++)
{
id=json[i].Id;
row=Ti.UI.createTableViewRow({
height:'60dp'
});
idLabel=Ti.UI.createLabel({
text:id,
font:{fontSize:'16dp'},
height:'auto',
left:'10dp',
top:'5dp',
color:'orange',
touchEnabled:false
});
name=json[i].Name;
nameLabel=Ti.UI.createLabel({
text:name,
font:{fontSize:'16dp'},
height:'auto',
left:'10dp',
top:'5dp',
color:'orange',
touchEnabled:false
});
dept=json[i].Dept;
deptLabel=Ti.UI.createLabel({
text:dept,
font:{fontSize:'16dp'},
height:'auto',
left:'10dp',
top:'5dp',
color:'orange',
touchEnabled:false
});
email=json[i].Email;
emailLabel=Ti.UI.createLabel({
text:email,
font:{fontSize:'16dp'},
height:'auto',
left:'10dp',
top:'5dp',
color:'orange',
touchEnabled:false
});
mobile=json[i].Mobile;
mobileLabel=Ti.UI.createLabel({
text:mobile,
font:{fontSize:'16dp'},
height:'auto',
left:'10dp',
top:'5dp',
color:'orange',
touchEnabled:false
});
row.add(idLabel);
row.add(nameLabel);
row.add(deptLabel);
row.add(emailLabel);
row.add(mobileLabel);
tabledata.push(row);
}
table.setData(tabledata);
},
onerror:function(e){
Ti.API.debug("STATUS: " + this.status);
Ti.API.debug("TEXT: " + this.responseText);
Ti.API.debug("ERROR: " + e.error);
alert('There was an error retrieving the remote data. Try again.');
},
timeout:5000
});
xhr.open("GET",url);
xhr.send();
win1.add(table);
win1.open();
I am getting alert "There was an error retrieving the remote data.Try again".after click ok
Application Error
Uncaught syntaxError:Unexpected end of input at /index.html
i don't know what to do..
solution please..