paulcuth / starlight

A Lua to ES6 transpiler.
MIT License
186 stars 23 forks source link

How to send json object ? #48

Closed CriztianiX closed 7 years ago

CriztianiX commented 7 years ago

Is this posible ?

local input = window:jq('.autocomplete')
input:autocomplete({
    serviceUrl = '/ajax/suggest/banks',
    paramName = 'q',
    onSelect = function(suggestion)
        print(suggestion)
      --$(this).val(suggestion.data);
    end
})

I get:

VM935:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0 at Function.parse [as parseJSON] () at Object.d [as transformResult] (jquery.autocomplete.min.js:8) at Object. (jquery.autocomplete.min.js:8) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at A (jquery.min.js:4) at XMLHttpRequest. (jquery.min.js:4)

Here the js: https://pastebin.com/cFZw2PMr

paulcuth commented 7 years ago

Hi,

Apologies for the delay. Yes, this is possible; see example code here: http://jsbin.com/xequfupuzu/edit?html,console,output

Let me know if you need any more help.