1. #1
    Sencha User
    Join Date
    Nov 2013
    Posts
    6
    Vote Rating
    1
    shashi@sencha is on a distinguished road

      0  

    Default How to call Mock Services from sencha

    How to call Mock Services from sencha


    Hi All,

    I am facing a problem in calling services from my sencha code. Actually that services are not like (WCF, WebAPI etc), they are the mock services that I have created on
    http://apiary.io/ . since we all know that sometimes we may not have the services ready during the development and we cannot be dependent on the services for our development. So I have created this new mock services.

    but now I am facing issue in calling it.
    following is the code how I a calling it -

    Ext.Ajax.request({

    url: 'http://shashikantgiri.apiary.io/GetMatterSuggestions/Update',
    method: "GET",
    defaultHeaders:{
    'Content-Type': 'application/json; charset=utf-8'
    },
    jsonData: getMatterInfoRequestBody,


    success: function(response){
    debugger;
    var matterInfoResult = Ext.decode(response.responseText);
    var result = matterInfoResult.GetMatterSuggestionsResult;
    if(result)
    {
    var copiedRecord = rec.copy();
    var newRecord =Ext.Object.merge(copiedRecord.data,{'AreaOfLaw':result.AreaOfLaw ,'ClientId':result.ClientId, 'ClientLabel': result.ClientLabel,'ClientName': result.ClientName,
    'MatterDescription' : result.MatterDescription, 'MatterLabel': result.MatterLabel,'MatterName':result.MatterName, 'MatterType': result.MatterType, 'TotalHours': 0});
    combineStore.insert(i++ , newRecord );
    }
    },




    failure: function(){
    debugger;
    alert("fail");
    }
    });


    But it is showing following error.

    [/COLOR]
    [COLOR=red !important]XMLHttpRequest cannot load http://shashikantgiri.apiary.io/GetM...=1388732405183. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.


    Please help.[COLOR=red !important][/COLOR]
    [/COLOR]

  2. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,663
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      1  

    Default


    not sure if you are talking about ext js or touch, please use the correct forums.

    in case you want to access data on a different domain, you can use jsonp:
    http://docs.sencha.com/extjs/4.2.2/#...ta.proxy.JsonP

    you can also start your browser (e.g. chrome) with disabled cross domain restrictions.
    in case you whitelist your server, you can use ajax calls as well.

    take a look at the "CORS" concept:
    http://en.wikipedia.org/wiki/Cross-o...source_sharing
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar