Announcement

Collapse
No announcement yet.

Uncaught SyntaxError: Unexpected token : when using api

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Uncaught SyntaxError: Unexpected token : when using api

    when i try to get data from api i get this error in the console

    Code:
    user?callback=jQuery21406149524166248739_1436556997509&_=1436556997510:1 Uncaught SyntaxError: Unexpected token :

    Code:
        var creds = {
        username: "username",
        password: "password"
    };
    var credentials = btoa(creds.username + ":" + creds.password);
    $.ajaxSetup({
        xhrFields: { withCredentials: false },
        beforeSend: function (xhr, settings) {
            xhr.setRequestHeader("Authorization", "Basic" + credentials);
            return true;
        }
    });
    
    $.ajax({
        url: 'http://site.com/api/v1/App/user',
        type: 'GET',
        dataType: 'jsonp',
        async: false,
        success: function (data) {
            console.log(data);
        }
    });

  • #2
    i also tried: and the same error:
    Uncaught SyntaxError: Unexpected token :
    Code:
    var username = 'admin';
    var password = '1';
    
    $.ajax
    ({
      type: "GET",
      dataType: 'json',
      async: false,
      url: "http://demo.espocrm.com/basic/api/v1/App/user?callback=?",
      headers: {
        "Authorization": "Basic " + btoa(username + ":" + password)
      }
    })
    .done(function(){
        alert('Authenticated!')
    })
    .fail(function(){
        alert('Error!')
    });

    Comment


    • #3
      No clue what it is, Code seems to be correct.

      Comment


      • #4
        HI,
        if there is problem with the code maybe you can add working example to doc so we can have a start point.

        and whats wrong with this code?

        Comment


        • #5
          some help?

          Comment


          • #6
            Really have no time.

            Comment

            Working...
            X