0

I am trying to to use ajax and/or JSON for Web service restful which I have build and deployed with the Labview software.

However I get errors (parserror) For example. I have build a web service from a Labview vi (z =x/y localhost:8080/math/divide/5/20 will give {Z:"4.000000"} )

I get results when I run the web service with the browers (Chrome, Explorer or from Android application I have wrote) but I am getting errors for the below examples.

Below are 2 examples: ajax and getJSON

Does anyone know how to get data from the labview web service with ajax or json? Thanks...Eran

  • Example 1

    var url = "localhost:8080/math/math/5/20";
    $.ajax({
        dataType: "jsonp",
        ContentType: "application/json",
        headers: {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Methods": "GET"
        },
        url: url + '&callback=?',
    }).done(function (data,status) {
       alert(status);
    }).fail(function (data,status) {
       alert(status);
    });
    
  • Example 2

     $.getJSON("localhost:8080/math/divide/5/20&callback=?", function (data) {   
    
     }).done(function (data,status) {
           alert(status);
     }).fail (function (data,status) {
          alert(status);
     });
    
iConnor
  • 19,997
  • 14
  • 62
  • 97
TBW
  • 1
  • 2
  • If you expect people to help you you should take care that your questions are readable. What parsing error do you get? – t.niese Sep 07 '13 at 21:01

1 Answers1

0

jQuery validates the structure of your json when you use getJson or ajax/get with parameter json. The problem is your key field in {Z:"4.000000"}. This is not valid json. This is {"Z":"4.000000"}. Take a look here online json validator

What you could do (since you can access your json data from the browser) is test that data by pasting them in the online validator. When it marks it as valid make the changes you need.

UPDATE After the clarification it seems that although you are asking for JSONP, you are returning JSON. Check this for more json Uncaught SyntaxError: Unexpected token :

Community
  • 1
  • 1
Alkis Kalogeris
  • 17,044
  • 15
  • 59
  • 113