Reputation: 573
I have some Ajax that makes a Cross Origin Resource call
$("#inductive1").click(function (event) {
$.post(
"https://www.mysite.co.uk/folder/tests/Inductive/Test1/index.phtml",
function (data) {
$('.stage2').html(data);
}
);
});
within the index.phtml
file I have some Script that calls exam.xml
Script inside index.phtml
( function($, undefined) {
$(function() {
var test = new Test({
testName: "Inductive Test 1",
dataURL : "/getresultshtml.php",
sendEmailURL: "/sendresultsbyemail.php",
contentFolder : "./",
solutionURL: "../../../content/f/id/10/",
userID: 0,
courseItemID: 25,
XMLFile: "exam.xml",
isStandalone: false
});
test.start();
});
}(jQuery));
However the xml file is trying to be called from the other server,
EG
https://server1.com/exam.xml
it should be
https://myserver.com/exam.xml
I have tried changing the JS to direct path as in
XMLFile: "htttps:/myserver.com/exam.xml"
but it is being read as
https://server1.com/myserver.com/exam.xml
how do I change the javascript so that it changes the root URL to myserver.com
and not server1.com
Upvotes: 0
Views: 52
Reputation: 563
I'm not sure how the Test
will use the XMLFile
. But per the jquery.ajax documentation, passing the complete url (with the protocol) in the url
parameter should be enough.
Maybe the test.start()
is doing some manipulation?
The only other possible issue that I found is that you are declaring your protocol with an extra t
and a missing /
XMLFile: "htttps:/myserver.com/exam.xml"
Try using
XMLFile: "https://myserver.com/exam.xml"
Upvotes: 0
Reputation: 7676
Looks like some plugin you are using is changing document's base URL, you can try putting this at the beginning of index.phtml
<base href="https://myserver.com">
If that doesn't work you might need to dynamically change the base property through JavaScript just before the ajax call
document.write("<base href='http://myserver.com/'>");
Upvotes: 2