Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var produkty = ["4105882","4082398","4178248","4178256"]
- $.each(produkty, function(k,v){
- console.log (k+v);
- }
- )
- function createCORSRequest(method, url) {
- var xhr = new XMLHttpRequest();
- if ("withCredentials" in xhr) {
- // XHR for Chrome/Firefox/Opera/Safari.
- xhr.open(method, url, true);
- } else if (typeof XDomainRequest != "undefined") {
- // XDomainRequest for IE.
- xhr = new XDomainRequest();
- xhr.open(method, url);
- } else {
- // CORS not supported.
- xhr = null;
- }
- return xhr;
- }
- // Make the actual CORS request.
- function makeCorsRequest() {
- // This is a sample server that supports CORS.
- var url = 'https://nbsklep.pl/product/get_availability.html?variant_id=4105882&city=Bia%C5%82ystok';
- var data = new FormData();
- data.append("variant_id", produkty);
- var xhr = createCORSRequest('POST', url);
- if (!xhr) {
- alert('CORS not supported');
- return;
- }
- // Response handlers.
- xhr.onload = function() {
- var text = xhr.responseText;
- var json = JSON.parse(text);
- console.log(json)
- };
- xhr.onerror = function() {
- console.log('Woops, there was an error making the request.');
- };
- xhr.send(data);
- }
- makeCorsRequest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement