pass a JQUERY value to the window.open () function

2

How can I retrieve a value that comes from a request through JQUERY to a database and put this value into a window.open () function;

JQUERY

$(document).on("click", ".modal",  function () {
 var key  = $(this).data('numero');

 var url = 'http://www.exemplo.com&n='; 

 window.open(url, key);
});

If the return value was 1000 the code should form the following url:

link

    
asked by anonymous 04.08.2015 / 04:15

1 answer

4

As you want to append the value in the URL, which is just a string, do a simple concatenation:

var url = 'http://www.exemplo.com?n=' + key;
window.open(url)

The part of the url to pass parameters starts with ? and not & . The & is to separate key / value pairs.

    
04.08.2015 / 12:09