hi,
from doc:
{output, Output::iolist(), Headers::proplist()}
Skip views altogether and return Output to the client while setting
additional HTTP Headers.
in your case, should be:
index('GET', []) ->
{ok,Data} = file:read_file("./ln.json"),
{output,Data, [{"Content-Type","application/j-son;charset=UTF-8"}]}.
chan.
2015-12-12 5:07 GMT+08:00 Mert Öztürk <[email protected]>:
> Hello,
>
> I am struggling to get my json file through controller and get action. I
> tried with this below;
>
> index('GET', []) ->
> {ok,Data} = file:read_file("./ln.json"),
> {json,Data}.
>
> and also with;
>
> index('GET', []) ->
> {ok,Data} = file:read_file("./ln.json"),
> {json,binary_to_list(Data)}.
>
> Clientside:
>
> $.ajax({
> type: "GET",
> async: false,
> beforeSend: function(x) {
> if(x && x.overrideMimeType) {
> x.overrideMimeType("application/j-son;charset=UTF-8");
> }
> },
> dataType: "json",
> success: function(data){
> JSON = data
> }
> });
>
> I can read json file but couldnt send json data to client. Help will be
> appreciated.
>
> Thanks
> Mert
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ChicagoBoss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> Visit this group at http://groups.google.com/group/chicagoboss.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/chicagoboss/f20d5420-8732-4773-ad16-fd8a73577df6%40googlegroups.com
> <https://groups.google.com/d/msgid/chicagoboss/f20d5420-8732-4773-ad16-fd8a73577df6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/chicagoboss.
To view this discussion on the web visit
https://groups.google.com/d/msgid/chicagoboss/CAB-Ofhmt-ANwYkdA0yZq6nKFD%2B%3D701RajzQaxkMFLPG%2BNqWPuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.