User2413
User2413

Reputation: 615

Calling a jsp page through javascript call

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.

Upvotes: 1

Views: 6701

Answers (1)

Pradeep
Pradeep

Reputation: 90

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) {

          }
        });
}

Upvotes: 1

Related Questions