Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- var produkty = ["006184"]
- $.each (produkty, function (k,v){
- var nr_sklepow = ["710"]
- $.each (nr_sklepow, function (n,w) {
- // Make the actual CORS request.
- function makeCorsRequest() {
- // This is a sample server that supports CORS.
- var url = 'https://www.jula.pl/catalog/narzedzia-i-maszyny/elektronarzedzia-i-maszyny/wkretarki/wkretarki-akumulatorowe/zestaw-narzedzi-one-006184/GetWareHouseStock/';
- var vars = {
- data.append('storecode', w);
- data.append('productCode', v);
- }
- data.append(vars)
- 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