I have just built an AJAX function. Their are no errors with firebut and the correct response is returned but for some reason it will not fill the field value #crap of fill the div html #outdirections.

AJAX ::

```
function appdirections() {
    var start = $('#start').val();
    var end = $('#end').val();

    var dataString = 'start=' + start + '&end=' + end;

    $.ajax({
            type: 'POST',
             url: 'http://www.golfbrowser.com/courses/wentworth-east/?appdirections',
             data: dataString,
             beforeSend: function() {
                 },
                dataType:'json',
             success: function(data) {
     $('#outdirections').html(data.output);
     $('#crap').val(data.output);
},
      error: function(data) {
                 },
         });
}

```

PHP ::

```
<?php 

$start = $_POST['start'];
$end = $_POST['end'];

$xml = simplexml_load_file('http://maps.googleapis.com/maps/api/directions/xml?origin='.$start.'&destination='.$end.'&sensor=false');

// data to fetch

$start = $xml->xpath("/DirectionsResponse/route/leg/start_address");

$end = $xml->xpath("/DirectionsResponse/route/leg/end_address");

// output

echo json_encode( array('output'=>$start));

?>

```

HTML

```
<input type="text" id="crap" value=""/>

<div id="outdirections"></div>

<input id="start" type="text" spellcheck="false" placeholder="enter your post code" onkeypress="if (event.keyCode == 13) {appdirections();}"/>

<input id="end" type="text" value="wentworth virginia water" disabled="disabled"/>

```

Here is the response from Firebug

```
{"output":[{"0":"Winkfield, Windsor, Berkshire SL4 2ES, UK"}],"end":[{"0":"Wentworth, Surrey GU25 4, UK"}]}

```