Page 1 of 1

JSONP Jquery Auto Complete

Posted: Sat Oct 04, 2014 5:51 am
by Grandong
Help me please, i have the js code like :

Code: Select all

    <script type="text/javascript">
      function dohop_source(request,response){
        $.ajax({
          jsonp:"cb",
          url: "https://api.master18.tiket.com/search/autocomplete/hotel?token=63bc148f0862660af86b899ccd6e7f8ced00f861&output=json",
          dataType: "jsonp",
          data: {q: request.term},
          success: function(data) {
            response($.map(data.result, function(item) {
              return {
                label: item.label,
                value: item.value
              };
            }));
          }
         });
      }
      $(document).ready(
        function(){
          $("#a1").autocomplete({source: dohop_source,minLength: 2});
          $("#a2").autocomplete({source: dohop_source,minLength: 2});
          $("#d1").datepicker({numberOfMonths: 2,showButtonPanel: true, dateFormat: "dd.mm.y",minDate: new Date(),
            onSelect:function(text,inst){
              $("#d2").datepicker("option","minDate",$("#d1").datepicker("getDate"));
            }
          });
          $("#d2").datepicker({numberOfMonths: 2,showButtonPanel: true, dateFormat: "dd.mm.y",minDate: new Date()});
        }
      );
    </script>
Then, this my html :

Code: Select all

   <form action="#" method="GET">
     <table>
       <tr><th>From</th><td><input type="text" id="a1"  name="a1"/></td></tr>
       <tr><th>To</th><td><input type="text" id="a2" name="a2"/></td></tr>
       <tr><th>Depart</th><td><input type="text" id="d1" name="d1"/></td></tr>
       <tr><th>Return</th><td><input type="text" id="d2" name="d2"/></td></tr>
       <tr><td colspan="2" style="text-align:right;"><input type="submit" value="Search"></td></tr>
      </table>
    </form>
My Error :

Code: Select all

SyntaxError: missing ; before statement
{"diagnostic":{"status":"200","elapsetime":"0.0429","memoryusage":"4.52MB
this json result:

Code: Select all

{"diagnostic":{"status":"200","elapsetime":"0.0319","memoryusage":"4.54MB","unix_timestamp":1412419870,"confirm":"success","lang":"id","currency":"IDR"},"output_type":"json","results":{"result":[{"id":"business:111205","weight":"40681","distance":"121710.820312","skey":"2.991835","country_id":"id","label":"Bali Indah Hotel Bandung - Bandung, Regol, Ancol ","value":"Bali Indah Hotel Bandung","category":"Recomended Hotel","tipe":"business_id"},{"id":"business:20186653","weight":"40675","distance":"657435.187500","skey":"16.163126","country_id":"id","label":"Bali'ku Guest House - Batu, Batu, Ngaglik ","value":"Bali'ku Guest House","category":"Recomended Hotel","tipe":"business_id"},{"id":"business:131969","weight":"40672","distance":"882368.812500","skey":"21.694748","country_id":"id","label":"Taman Sari Bali Resort - Buleleng, Gerokgak, Pemuteran ","value":"Taman Sari Bali Resort","category":"Recomended Hotel","tipe":"business_id"}]},"login_status":"false","token":"63bc148f0862660af86b899ccd6e7f8ced00f861"}
HELP PLEASE.. :(