RAVITEJA SATYAVADA
RAVITEJA SATYAVADA

Reputation: 2571

how to another url in jquery

I am new to jquery. I want to call a jsp page from jquery. In javascript i used as,

  $("#submit").click(function(){
         var spid=$('#heading').text();
         window.open('salesplanvalidation.jsp?salespersonid='+spid,target='_self');
   });

In jquery it is not working. If i removed the target option then it is working but the new jsp page is loading into another tab and the parameter salespersonid is not passing there. What i have to do now??

Upvotes: 0

Views: 232

Answers (2)

Joseph Silber
Joseph Silber

Reputation: 219938

If you're trying to open it in your current tab, use this:

$("#submit").click(function(){
    var spid = $('#heading').text();
    window.location = 'salesplanvalidation.jsp?salespersonid=' + spid;
});

However, if you want to open it in a new tab, use this:

$("#submit").click(function(){
    var spid = $('#heading').text();
    window.open('salesplanvalidation.jsp?salespersonid=' + spid);
});

Upvotes: 2

Jasper
Jasper

Reputation: 76003

How about redirecting the user to the new page using the location object:

$("#submit").click(function(){
    var spid=$('#heading').text();
    location = 'salesplanvalidation.jsp?salespersonid='+spid
});

Upvotes: 2

Related Questions