Wednesday, November 13, 2013

Get Ajax respone data from outside of success handler

 You must use async false in ajax

<script type="text/javascript">
var ajaxResponse;
    
    $.ajax({
            type: "POST",
            url: "get_price.php",
            async: false,
            data: "var"+var1,
            cache: false,
            success: function(response){
                ajaxResponse  = response;
            }
        });        

alert(ajaxResponse);
</script>
 

No comments:

Post a Comment