Click here to Skip to main content
15,883,710 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I created a json using WCF . my link in browser
"http://localhost:52849/restfullservice/Service1.svc" shows

CSS
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://localhost:52849/RestFullService/Service1.svc?wsdl
 You can also access the service description as a single file:

 http://localhost:52849/RestFullService/Service1.svc?singleWsdl

and
C#
http://localhost:52849/restfullservice/Service1.svc/getdetails  gives json data

 [{"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:

C#
var win1 = Titanium.UI.createWindow({
  backgroundColor:'white'
   });

  var url="http://localhost:52849/restfullservice/Service1.svc/getdetails";
  // Create a TableView.
  var table = Ti.UI.createTableView();

  // Populate the TableView data.
   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..
Posted
Updated 2-Apr-14 4:23am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900