Why this always return "undefined"
Hi every, I have this two HTML select (consigna_id depends on manufacturer_id selection):
- <select id="manufacturer_id" name="manufacturer_id">
- <option selected="selected" value="0"> --- Ninguno --- </option>
- <option value="6">Júpiter Ediciones 9. C.A.</option>
- <option value="2">Proveedor 1</option>
- <option value="3">Proveedor 2</option>
- <option value="5">Proveedor 3</option>
- <option value="4">Proveedor 4</option>
- </select>
- <select disabled="disabled" id="consigna_id" name="consigna_id">
- </select>
And then have this jQuery code to get data dinamically via AJAX:
- // Search consigna based on manufacturer
- $("#manufacturer_id").change(function(){
- $.ajax({
- url: 'index.php?route=catalog/product/getConsignaManufacturer& token=11a3c350e29c157da32ea947b3aa9b29&manufacturer_id=' + $('#manufacturer_id').val(),
- type: 'GET',
- dataType: 'json',
- success: function(dato){
- alert(dato.consigna_id);
- $("#consigna_id").empty().removeAttr("disabled").append(dato.consigna_code);
- }
- });
- });
The function return data as follow:
[{"consigna_id":"4","manufacturer_id":"2","consigna_code":"f3150877","date":"2011-03-03","date_added"
:"0000-00-00 00:00:00","date_modified":"0000-00-00 00:00:00"}]
But the message "undefined" appears any time I try to access some JSON property, for example dato.consigna_id wich is fine because I use the same sintaxis in others parts and works fine. Why this fail?
Cheers and thanks in advance