0

I'm using the below code in a SharePoint Online Add-in to import data from a text file to my HTML:

$.getJSON("../Content/timeszones.txt", function (data) {
    $.each(data.items, function (i, item) {
        $('#timezone').append(`<option value=${item.UTCDSTOffset}>${item.TZ}</option>`);
    })
}, console.log("fail"));

I'm getting the error:

HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier). (XHR)GET - https://mySite.sharepoint.com/sites/develop_apps/WorldClock/Content/timeszones.txt

My configuration is as follows and I've verified the file is included in the feature: Configuration Feature

What am I missing?

1 Answer 1

1

Probably the location "../Content/timeszones.txt" in your JS code is not correct. You should check where your timezones.txt is deployed to according to the definition in the Elements.xml and change the url in the JavaScript code accordingly. I would recommend to use a server relative Url in the JS code.

1
  • You're correct: I identified a typo by looking at Elements.xml - thank you
    – dikuw
    Jan 12, 2018 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.