У меня есть код ниже, который внезапно перестал работать.Автозаполнение не приводит к каким-либо результатам.
Я создал временную форму для ручной отправки данных, она возвращает данные json в порядке.Затем я проверил, что ajax на самом деле делает запрос, сохраняя json в текстовый файл при вызове страницы, и это работает.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Customer Management System</title>
<link type="text/css" href="http://localhost/stack_ci_2/public_html/includes/jquery/css/smoothness/jquery-ui-1.8.5.custom.css" rel="stylesheet" />
<script type="text/javascript" src="http://localhost/stack_ci_2/public_html/includes/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://localhost/stack_ci_2/public_html/includes/jquery/jquery-ui-1.8.5.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// Get matches for customer search.
$("#customer_search_ref").autocomplete({
minLength: 2,
source: function(request, response) {
$.ajax({
url: "<?php echo site_url('customer/ajax_customer_search'); ?>",
data: { term: $("#customer_search_ref").val()},
dataType: "json",
type: "POST",
success: function(data){
response(data);
}
});
},
// Inputs customer data into forms.
select: function(event, ui){
$("#customer_name").focus();
$("#tabs").tabs("select",0);
}
});
});
Данные JSON возвращаются при ручной публикации и в текстовом файле.
[{"id":"114","name":"Claire","surname":"Taylor","address_1":"add1","address_2":"add2","address_3":"add3","city":"city","county":"county","postcode":"postcode","country":"country","email":"email","home_tel":"home","mobile_tel":"mobile","work_tel":"work","notes":"notes","value":"Claire Taylor - 114","label":"114 - Claire Taylor"}]
Я подумал, что это может быть не возвращаемая метка и значение, но это так.
Также успешно загружаются файлы js и css, и XHR-запросы проверяют все это в firebug.
Есть идеи?