JavaScript DOM Error in Ajax call only in Safari 9.0 error ajax call,error ajax call jquery,ajax error call

I have following code in my javascript

var _csrf = $("#csrf_token").val();

        var xhr = $.ajax ({

            url : 'http://ip.jsontest.com/',
            type : 'GET',
            contentType : 'application/json',
            headers : {

                        "csrf" : _csrf
                    }
        })
        .done(function(data){

            alert('done');   

        })
        .fail(function(data){

            alert(data["statusText"]);
        })
        .always(function(data){

            alert('always');

        })

csrf_token is HTMl is as below

<input type="hidden" value=" {{ csrf_token }}" id="csrf_token" >

The result I am getting when calling this ajax call is Error: SyntaxError: DOM Exception 12 if fail; block.

But when remove the csrf header, alerts in done block and always block is called.

Same code works fine in Chrome and doesn't throw any DOM error.

Any help to solve this issue is appreciated.

Thank you

EDIT

I have tried with a different filed In HTML:

In JS

 var c = $("#sessionId").val()
 var xhr = $.ajax ({

        url : 'http://ip.jsontest.com/',
        type : 'GET',
        contentType : 'application/json',
        headers : {

                    "identifier" : cookie
                }
    })
    .done(function(data){

        alert('done');   

    })
    .fail(function(data){

        alert(data["statusText"]);
    })
    .always(function(data){

        alert('always');

    })

still same issue

Answer:1

I'm trying to run this jestJS unit-test, but I do get TypeError: Promise resolver undefined is not a function. What am I doing wrong? it('_onSubmit() should throw error if data is missing', (done) =&...

I'm trying to run this jestJS unit-test, but I do get TypeError: Promise resolver undefined is not a function. What am I doing wrong? it('_onSubmit() should throw error if data is missing', (done) =&...

  1. promise resolver is not a function

I need to use a google projects service account to access google API using JavaScript. In order to do this I need to OAuth2 to google API servers to get an auth token. I understand that Google ...

I need to use a google projects service account to access google API using JavaScript. In order to do this I need to OAuth2 to google API servers to get an auth token. I understand that Google ...

  1. retrieve service account password
  2. cannot retrieve service account
  3. retrieve windows service account password
  4. cannot retrieve service account openshift
  5. retrieve managed service account password
  6. openshift build cannot retrieve service account

Consider a radiobutton HTML element in an angular application, <div class="radio"> <label> <input type="radio" name="approvedeny" value="true" [(ngModel)]=_approvedOrDenied&...

Consider a radiobutton HTML element in an angular application, <div class="radio"> <label> <input type="radio" name="approvedeny" value="true" [(ngModel)]=_approvedOrDenied&...

Suppose I need to implement a simple join function that takes an array and returns a concatenated string of elements separated by a separator. Kind of what built-in method Array.prototype.join does. ...

Suppose I need to implement a simple join function that takes an array and returns a concatenated string of elements separated by a separator. Kind of what built-in method Array.prototype.join does. ...