Send data by url with jquery

0

How is the data sent by url in jquery? I have an example in native js and I want to pass it to jquery

        var f2=document.getElementById('fechaFinal').value;
        window.location.href='localhost/reporte.php?f2='+f2;
    
asked by matteo 27.01.2017 в 23:51
source

2 answers

2

You can do it with

$(location).attr('href',URL_PAGINA_WEB); 

Where location corresponds to window.location

href is the attribute href and% URL_PAGINA_WEB will be% localhost/reporte.php?f2='+f2

Here you can see a little more like everything works

    
answered by 27.01.2017 / 23:59
source
2

you can use the $ .get () method;

var params = {
   param_1 : $("#input1_id").val(),
   param_2 : $("#input2_id").val(),
   ....
   param_n : $("#inputN_id").val()
};

$.get(URL, params, function(e){
    // algo que quieras hacer despues de enviar la petición.
});

At the end of the URL the parameters are concatenated with &, and server-side you get them with the verb $ _GET, luck !!.

    
answered by 28.01.2017 в 02:11