Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX functionless
    primarykey
    data
    text
    <p>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.</p> <p>AJAX ::</p> <pre><code>function appdirections() { var start = $('#start').val(); var end = $('#end').val(); var dataString = 'start=' + start + '&amp;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) { }, }); } </code></pre> <p>PHP ::</p> <pre><code>&lt;?php $start = $_POST['start']; $end = $_POST['end']; $xml = simplexml_load_file('http://maps.googleapis.com/maps/api/directions/xml?origin='.$start.'&amp;destination='.$end.'&amp;sensor=false'); // data to fetch $start = $xml-&gt;xpath("/DirectionsResponse/route/leg/start_address"); $end = $xml-&gt;xpath("/DirectionsResponse/route/leg/end_address"); // output echo json_encode( array('output'=&gt;$start)); ?&gt; </code></pre> <p>HTML</p> <pre><code>&lt;input type="text" id="crap" value=""/&gt; &lt;div id="outdirections"&gt;&lt;/div&gt; &lt;input id="start" type="text" spellcheck="false" placeholder="enter your post code" onkeypress="if (event.keyCode == 13) {appdirections();}"/&gt; &lt;input id="end" type="text" value="wentworth virginia water" disabled="disabled"/&gt; </code></pre> <p>Here is the response from Firebug</p> <pre><code>{"output":[{"0":"Winkfield, Windsor, Berkshire SL4 2ES, UK"}],"end":[{"0":"Wentworth, Surrey GU25 4, UK"}]} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload