Hello
I'm having problems with JSON
when I upload it to the server ..
Example of one of my code that uses JSON
:
$("input[name=people]").keyup(function(){
if($(this).val() != ''){
$.ajax({
url: "<?php echo site_url('/StockController/searchPeople')?>",
type: "POST",
cache: false,
data: {name_people: $(this).val()},
success: function(data){
$('#loadPeople').html("");
var obj = JSON.parse(data);
if(obj.length>0){
try{
var items=[];
$.each(obj, function(i,val){
items.push($("<option id="+ val.id_people +">"+ val.name +"</option>"));
});
$('#loadPeople').append.apply($('#loadPeople'), items);
}catch(e) {
alert('Ocorreu algum erro ao carregar os Fornecedores!');
}
}else{
$('#loadPeople').html($('<span/>').text("Nenhum Fornecedor encontrado!"));
}
},
error: function(data){
alert("Ocorreu algum erro ao carregar os Fornecedores");
}
});
}else{
$('#loadPeople').html(" ");
}
});
On the local server it runs smoothly, but when I upload it to an online one the code stops working, and returns the following error in the console:
Uncaught SyntaxError: Unexpected token in JSON at position 0
Does anyone know what might be happening?