Monday, 12 August 2013

On page javascript is not getting executed

On page javascript is not getting executed

I am added one java-script function call on my jsp page and for one use
cases it is working fine while for other flow this is not getting
executed.
here is code snap shot
<c:choose>
<c:when test="some test">
some jsp code
<script>
setAutoShippingMode();
</script>
</c:when>
<c:otherwise>else condition</c:otherwise>
</c:choose>
In both cases, system is entering in when condition for first flow, it is
calling java script function perfectly fin, but for second condition, java
script function is not getting triggered at all
this behavior is consistent in all browser. Can any one help me to
understand me as why this is happening as i do not see any issue in coding
part (in both cases code is entering in same block)
JS method
function setAutoShippingMode(){
console.log("setAutoShippingMode method");
var modeValue = $('#single_delieveryModeValue').val();
$.ajax({
type : 'POST',
url : $("#currentContextPath").val()+"/checkout/summary
/setDeliveryMode.json?modeCode="+modeValue+'&bustcache='+new
Date().getTime(),
success : function(response) {
// some post success logic
},
error : function(e) {
// error section
}
});
}
JSP from browser
<div class="button2" id="id3">Method</div>
<input type="hidden" name="unfdeliveryModeValuesLength" value="1"/>
<input type="hidden" name="delieveryModeValue"
id="single_delieveryModeValue" value="Value" />
<script>
setAutoShippingMode();
</script>

No comments:

Post a Comment