Hi, > var html = $.ajax({ > type: "POST", > url: "get_file_contents.php", > data: "mod_index=" + p_moduleIndex, > dataType: "html", > error: function(req, errorMsg) { > alert("An error occurred: " + errorMsg); > } > }).responseText;
$.ajax() does an _assynchronous_ XMLHttpRequest. It returns immediatelly and does not wait for the request to finish. After the call has returned the text can simply not be there. Try it this way: function loadModuleHTML(p_id, p_moduleIndex) { $.ajax({ type: "POST", url: "get_file_contents.php", data: "mod_index=" + p_moduleIndex, dataType: "html", error: function(req, errorMsg) { alert("An error occurred: " + errorMsg); } success: function(h) { alert(h); $('#'+p_id).html(h); // yes, that is what jQuery is for } }); } Christof _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/