How to catch the JSON return via jQuery?

Asked

Viewed 9,442 times

3

I have a link from Click to Call that returns me a JSON. How to proceed to retrieve 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":"" }
  • If you’ve tried something edit the question by posting the code.

  • You use Asp.net C#?

2 answers

6

Using the $.getJSON(). For example:

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

    alert( data.acctid );

});
  • I’ve tried that, but he won’t return

  • it does not return because I am having a cross-Omain problem

  • @Johnatandantas Take a look here: http://answall.com/questions/12363/comor-effectives-requisicoes-ajax-com-jquery-em-differentdomains

2

It has several forms, 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
            ....
        }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.