Skip to Content
avatar image
Former Member

json file is not found

I am trying to access my json file which is in model folders through my xml view but its showing me the following error

The following problem occurred: error - <html><head></head><body>File sap/zclub5/model/club/json NOT found!</body></html>,404,NOT FOUND

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 03, 2017 at 10:33 AM

    Hi,

    Try the below code

    var model =newsap.ui.model.json.JSONModel();
    var path = jQuery.sap.getModulePath("club");
    
     //for the below code too work you have to move your model folder inside the club folder 
    model.loadData(path +"/model/club.json");
     //else use below code
    
    model.loadData(path +"/../model/club.json");
    
    
    

    Regards,

    Suriya

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 03, 2017 at 09:01 AM

    Hey Yadnesh,

    Please try this code in you controller:

    var model = new sap.ui.model.json.JSONModel();
    var path = jQuery.sap.getModulePath("club");
    model.loadData(path + "/model/club.json");
    var _self = this;
    model.attachRequestCompleted(function(){
    _self.getView().setModel(model);
    });

    Regards

    GB

    
                                                
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 03, 2017 at 08:40 AM

    These are the files i have used in my app

    view file view.png

    controller file controller.png

    index file index.png

    json json.png

    Add comment
    10|10000 characters needed characters exceeded