Pass variables on the getjson XDK URL Intel

0

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

I tried these two ways and I could not.

//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');
        }
    });     
});

Can anyone help me?

    
asked by anonymous 21.07.2016 / 15:43

2 answers

0

Hello, Pass the parameters with /

Example

$.get('suaUrl/paramentro1/paramentro2', suaFuncaoRetorno);
function suaFuncaoRetorno(itens){
  console.log(itens);
}
    
21.07.2016 / 16:08
0

Hello, Forget the $ .get. Only $ .AJAX already solves your problem. Here's how to call your delphi routine, but I do not think it's any different from the other forms. If it was in php urlSoma='somanumeros.php' , in delphi I do not know how it is.

p1 and p2 are the numbers you want to add. Json is the return. It depends on your role 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');
        }
    });     
})

;

    
02.01.2017 / 14:51