mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
cors
This commit is contained in:
parent
559cf8cf4b
commit
05c8c7c784
@ -56,8 +56,8 @@
|
|||||||
// find page in category
|
// find page in category
|
||||||
// **********************************************
|
// **********************************************
|
||||||
this.findPagesInCategory = function(domain, category) {
|
this.findPagesInCategory = function(domain, category) {
|
||||||
// run ajax
|
// run ajax; NOTE: must specify origin to bypass CORS; http://stackoverflow.com/a/38921370
|
||||||
var url = 'https://' + domain + '/w/api.php?action=query&format=json&formatversion=2&list=categorymembers&cmlimit=' + wm.category.excerptsMax + '&cmtitle=Category:' + category;
|
var url = 'https://' + domain + '/w/api.php?action=query&format=json&formatversion=2&origin=*&list=categorymembers&cmlimit=' + wm.category.excerptsMax + '&cmtitle=Category:' + category;
|
||||||
wm.category.runAjax(url, wm.category.findPagesInCategoryCallback);
|
wm.category.runAjax(url, wm.category.findPagesInCategoryCallback);
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
@ -117,8 +117,8 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// run ajax
|
// run ajax; NOTE: must specify origin to bypass CORS; http://stackoverflow.com/a/38921370
|
||||||
var url = 'https://' + wm.category.domain + '/w/api.php?action=query&format=json&formatversion=2&prop=extracts&exintro=1&explaintext&titles=' + category.title;
|
var url = 'https://' + wm.category.domain + '/w/api.php?action=query&format=json&formatversion=2&origin=*&prop=extracts&exintro=1&explaintext&titles=' + category.title;
|
||||||
wm.category.runAjax(url, wm.category.getExcerptCallback);
|
wm.category.runAjax(url, wm.category.getExcerptCallback);
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
@ -233,10 +233,10 @@
|
|||||||
// utility
|
// utility
|
||||||
// **********************************************
|
// **********************************************
|
||||||
this.runAjax = function(url, callback) {
|
this.runAjax = function(url, callback) {
|
||||||
var req = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
req.onreadystatechange = callback;
|
xhr.open("GET", url, true);
|
||||||
req.open("GET", url, true);
|
xhr.onreadystatechange = callback;
|
||||||
req.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(window.wm = window.wm || {}));
|
}(window.wm = window.wm || {}));
|
||||||
|
Loading…
Reference in New Issue
Block a user