Hello,
I like to work with JSON and jquery. When I test the script offline on localhost it works fine, but when I change this json file to a server it doens't work al all
jQuery(function($) {
$.ajax
({
type: "GET",
url: "test.php",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: companySearchSuccess,
error: onError
});
function companySearchSuccess(json)
{
alert("stap1");
var select = $('#city-list');
$.each(json, function(k, v) {
var option = $('<option />');
option.attr('value', v)
.html(v)
.appendTo(select);
});
}
function onError(m){
alert("Fout is: "+m);
}
});
This works fine,
but this one not:
jQuery(function($) {
$.ajax
({
type: "GET",
url: "http://www.example.com/test.php",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: companySearchSuccess,
error: onError
});
function companySearchSuccess(json)
{
alert("stap1");
var select = $('#city-list');
$.each(json, function(k, v) {
var option = $('<option />');
option.attr('value', v)
.html(v)
.appendTo(select);
});
}
function onError(m){
alert("Fout is: "+m);
}
});
The error is: object xmlhttprequest>
Please help me