How to get the JSON return via jQuery?

3

I have a Click to Call link that returns me a JSON. How do I get the data generated in JSON via jQuery?

Link:

http://192.168.0.6:8080/G4FlexWS/rest/flexuc/clicktocall/ext/telefoneOrigem/telefoneOrigem/telefoneDestino

Return in JSON:

{"acctid":"1401278513.28186", "status": "0", "erro":"" }
    
asked by anonymous 28.05.2014 / 14:29

2 answers

6

Using $ .getJSON () . For example:

$.getJSON("http://192.168.0.6:8080/G4FlexWS/rest/flexuc/clicktocall/ext/telefoneOrigem/telefoneOrigem/telefoneDestino", function(data) {

    alert( data.acctid );

});
    
28.05.2014 / 14:37
2

It has several forms, it follows two examples:

$.ajax({
    url: 'sua-url',
    type: 'POST',
    dataType: 'json',
    data: {seus-dados},
    success: function(data)
    {
        var acctid = data.acctid
        var status = data.status
        ....
    }

or

    $.ajax({
        url: 'sua-url',
        type: 'POST',
        data: seus-dados,
        success: function(data)
       {
            var response = $.parseJSON(data); 
            var acctid = response.acctid
            var status = response.status
            ....
        }
    
14.07.2017 / 02:00