I have a requirement where I need to execute the second function after the completion of an AJAX call in the first function (which involves reloading the page). Can you assist me with this? Here is the code snippet:
<div id="exapnd_or_collapse_div" class="exapnd_or_collapse_div" onclick="changeLayout();">
<script>
function changeLayout () {
alert('change layout');
try {
jQuery.ajax({
url:'<%=resourceURL.toString()%>',
dataType: "text",
data:{
<portlet:namespace />cmd:'changeLayout'
},
error: function(){
alert("AJAXError");
},
type: "post",
success: function(data) {
if("success" == data) {
location.reload();
}
}
}).done(function(){
exapndCollapse();
});
} catch(e) {
alert('waiting: ' + e);
}
};
function expandCollapse() {
jQuery("div.Search_Styled-dropDown").css("display", "none");
jQuery("span.menu-text").css("display", "none");
jQuery("ul.Common_ul").css("display", "none");
jQuery("img.module_images").css("width", "25px");
jQuery("img.module_images").css("margin-top", "20px");
jQuery("img.module_images").css("height", "21px");
jQuery("#search_box").css("display", "none");
jQuery("#Escaped_toggle").css("margin-right", "94%");
}
</script>