JSON with php and Jquery

kytoro

New Member
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\[code\] 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);}});\[/code\]This works fine,but this one not:\[code\] 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);}});\[/code\]The error is: object xmlhttprequest>Please help me
 
Back
Top