In my projects I work with the MVC api. I am trying to obtain this (and other) data with a full url via AJAX in: url: http://urlexample.com
This give an error: cross origin request blocked
what am I doing wrong? and who can help me? There is a lot to read about this problem, but so far nosolution yet for me.
This is my code:
<script type="text/javascript">
function loadstudentid() {
$.ajax({
// url: '/api/AZstudent', // > work fine
// url: 'http://<domain>.<subdomain>/api/azstudent', > // Gives te issue
cache: false,
dataType: 'json',
success: function (data) {
$(data).each(function (i, item) {
$(item).each(function (i, stud) {
console.log(stud.id_student);
});
});
},
error: function (request, status, error) {
console.log('error', error);
}
});
}
Wy is this working??
<script type="text/javascript">
function doewat() {
var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
$.getJSON( flickerAPI, {
tags: "mount rainier",
tagmode: "any",
format: "json"
})
.done(function( data ) {
$.each( data.items, function( i, item ) {
$( "<img>" ).attr( "src", item.media.m ).appendTo( "#images" );
if ( i === 3 ) {
return false;
}
});
});
}
//)();
http://api.jquery.com/jquery.getjson/
tried the following
jQuery.support.cors = false;
and
crossDomain: true,
and:
var url = 'http://myurl.com/api'