1

Script code

<script type="text/javascript">

function checkStatus(){
var productid=$("#productCode").val();
var Email=$("#productEmail").val();
$.ajax({ 
    type:'post', 
    data : {Email : Email},
    url:'', 
    }).success(function(status) { 
    success(status); 
    }); 
}

function success(status) {
alert("data is" +status);
    if (status != null && status===true) {
        alert('Success');
        $('#showMessage').show();
        $('#showbecomepartnerMessage').hide();
    } else {
        alert('Error');
        $('#showbecomepartnerMessage').show();
        $('#showMessage').hide();
    }

}
</script>

html messages code :(which i want to display in another jsp)

<div id="showpartMessage" class="2" style="display: none;">
                                <h5 style="color: #1ea59e;">Email not saved</h5>
</div>

<div id="showMessage" class="2" style="display: none;">
                                <h5 style="color: #1ea59e;">Email is saved</h5>
</div>  

I have an ajax call which returns me true or false value.According to this true or false value i will be showing and hiding the div messages.

I have a jsp layout in which different jsp(components) pages are clubbed(integrated).So my requirement is i want to make a javascript call from a jsp page to another jsp page without opening any new window. Is it possible??any help would be appreciated.

Note : Both the jsp pages are inside same layout ie; clubbed in one another jsp layout.

5
  • clubbed means, a.jsp is includes in b.jsp? Commented Sep 3, 2015 at 16:45
  • @Satya No a.jsp and b.jsp are together in c.jsp... Commented Sep 3, 2015 at 16:46
  • so you makes ajax call in c.jsp? Commented Sep 3, 2015 at 16:48
  • no i make ajax calls to controller...and get some true or false value...so according to that i have to display the message...so i want to display that message in another jsp by calling through javascript function Commented Sep 3, 2015 at 16:54
  • if you make a ajax call in c.jsp the result should be displayed in some other jsp page a.jsp its already included in c.jsp. is it correct. Commented Sep 3, 2015 at 17:01

1 Answer 1

1

1) First example

Opening the JSP page in a separate popup window using JavaScript function - window.open(); eg: window.open(MyPage.jsp)

2) Second example

<script language="JavaScript"> 
function updateStats(){ 
var jspcall="url.jsp" 
window.location.href=jspcall 
} 
</script>

3) Third example

function getInput()
{
    $.ajax({
        type:"POST",    
        url: "jsp/Ajax.jsp",
        data:"name=john",         
          success: function(success) {

          }
        });
}
Sign up to request clarification or add additional context in comments.

4 Comments

i want to call jsp inside success function...and without opening any window....refresing page is ok...
success : function(data) { windows.location.href='/myJSP.jsp; });
its ok but i want to print a succes message and fail message according to the value in that myJSP.jsp is that possible??
Please try this window.location.href ="/myJSP.jsp?PostData1=SomeThing1&PostData2=SomeThing2"; stackoverflow.com/questions/22252184/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.