Jump to content
Vladimir

mJSONP.Request problem

Recommended Posts

Hello!!
I have some problem and I'm trying to fix it. I raised my REST server and when I sent the request mJSONP.Request ('http://93.87.76.76:8080/drzave'); I persistently get the answer: Uncaught SyntaxError: Unexpected token <[line # 1]. Please, some can help me to solve the problem? At this address can see how the server response looks. Thanks a lot!

Share this post


Link to post
Share on other sites

Best way to get that JSON is by reading the contents with a normal TW3HttpRequest and converting it to a variant:
 

uses
...
  SmartCL.Net.Http,
  System.Json;

...

var JsonResponse: Variant;
begin
  var Req:=TW3HttpRequest.Create;
  Req.OnDataReady := procedure(Sender: TW3HttpRequest)
    begin
      JsonResponse := JSON.parse(Sender.ResponseText);
      for var i:=0 to Length(JsonResponse.drzave)-1 do
        WriteLn(JsonResponse.drzave[i].naziv);
    end;
  Req.Get('http://93.87.76.76:8080/drzave');

 

Share this post


Link to post
Share on other sites

Sorry, maybe I'm boring, but only one more problem. When I performed in the Smart Mobile Studio, everything worked right, but when I run it in a browser (like Chrome), I get the following error messages and nothing is done .

Failed to load http://93.87.76.76:8080/drzave: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

VM62:1 Uncaught SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Object.W3Button1Click.Req$1.OnDataReady (index.html:16974)
    at Object.HandleReadyStateChange (index.html:17162)
    at XMLHttpRequest.<anonymous> (index.html:396)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...