Benjamin Oats Benjamin Oats - 1 year ago 82
Javascript Question

CORS post index file with XML call

I have some Ajax that makes a Cross Origin Resource call

$("#inductive1").click(function (event) {
function (data) {

within the
file I have some Script that calls

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



However the xml file is trying to be called from the other server,


it should be

I have tried changing the JS to direct path as in

XMLFile: "htttps:/"

but it is being read as

how do I change the javascript so that it changes the root URL to
and not

Answer Source

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="">

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=''>");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download