Pass variables in the Intel getjson XDK URL

Asked

Viewed 98 times

0

I started to study javascipt now and I need to pass two variables to a sum method with getJSON and I don’t know how to do it. I created my app with XDK Intel, the server created with Delphi xe2 using datasnap.

I tried these two ways and I couldn’t.

//alert('acessou a rotina');    
$.get(urlSoma).then(function(data){

    alert(data);   
    //$("#iptResult").val();
    //$("#iptResult").val(data.result);    

}).fail(function(jqXHR,status,error){        
    alert(error);
});


$.ajax({
        url: urlSoma,
        type: 'GET',
        dataType: 'json',
        data: {x: pX},
        success: function(json){
            alerta('fungo');
        },
        error: function(json){
            alert('erro');
        }
    });     
});

Someone can help me?

2 answers

0

Hello, Forget $.get. Only $.AJAX already solves your problem. Look at the call your routine made in Delphi, but I believe it is not different from the other forms. If it were in php urlSoma='somanumeros.php', in Delhi I don’t know how it gets.

P1 and P2 are the numbers you want to add. json is the return. It depends on its function on the server-side.

$.ajax({
        url: urlSoma,
        type: 'GET',
        dataType: 'json',
        data: {p1: numero1,
               p2: numero2},
        success: function(json){
            alerta('fungo');
        },
        error: function(json){
            alert('erro');
        }
    });     
})

;

0

Hello, Pass the parameters with /

Example

$.get('suaUrl/paramentro1/paramentro2', suaFuncaoRetorno);
function suaFuncaoRetorno(itens){
  console.log(itens);
}

Browser other questions tagged

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