I'm using intl-tel-input, jQuery plugin for international phone numbers, for one of my projects. The plugin claims to "Automatically set the input placeholder to an example number for the selected country", but I can't get that to work properly. So far I tried 2 things:
1) I downloaded the library and referenced one of its JS files from my code ( similar to the demo). Here's a snippet of my JS file:
$("#phone").intlTelInput({
allowExtensions: false,
autoFormat: true,
autoHideDialCode: false,
autoPlaceholder: true,
defaultCountry: "ng",
ipinfoToken: "yolo",
nationalMode: true,
numberType: "MOBILE",
onlyCountries: ['ng', 'us', 'gb'],
preferredCountries: [],
utilsScript: "/projects/intl-tel-input-master/lib/libphonenumber/build/utils.js"
});
but I got the following error in the JS console of Chrome:
XMLHttpRequest cannot load file:///projects/intl-tel-input-master/lib/libphonenumber/build/utils.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
2) I put the library folder on a server and referenced utils.js file with server url (http://web.mit.edu/aizhan/www/intl-tel-input-master/lib/libphonenumber/build/utils.js). This still doesn't work on my machine, but it works in codepen with HTTP protocol but not with HTPPS:
HTTP: http://codepen.io/atoregozh/pen/raEPbv
HTTPS: https://codepen.io/atoregozh/pen/MYMLXv
My overall question: how could I make the library work locally? I also have 2 subquestions: 1) How to fix the error about XMLHttpRequest loading? (I read about it before from other posts on stackoverflow and I don't want to mess with the security settings); 2) Why the code works through HTTP but not through HTTPS?
I would really appreciate your help. If you want to see the actual project code, the index.html file is here and Javascript file is here