Consider following code where I try load jquery-ui only when a popup is needed. This code will be invoked when user click on a link
$.when( $.ajax({url: "http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css", dataType: "html", cache: true}),
$.ajax({url: "http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js", dataType: "script", cache: true}),
$.ajax({url: "../../plugins/jquery.dialogextend.js", dataType: "html", cache: true}) )
.then(
function() { ...code for dialog goes here
This code fails because jquery-ui.css will not load due to same origin policy. error message is " The Same Origin Policy disallows reading the remote resource at http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css. This can be fixed by moving the resource to the same domain or enabling CORS"
Now I am confused and trying to find out answer to the below two questions
In this code, jquery-ui.min.js is loaded but jquery-ui.css is not loaded. Due to same origin policy, if jquery-ui.css is not loaded, how jquery-ui.min.js is loaded?
When we include jquery-ui.css in the headed, as
<link href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css"it will load. Why same origin policy is not applicable here
Please help me to understand this.