Skip to content

Commit

Permalink
display friendly message if no data is received from ajax
Browse files Browse the repository at this point in the history
include usage examples:  example.html
  • Loading branch information
TomK committed Apr 26, 2012
1 parent 46d5b64 commit bdc1740
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
51 changes: 51 additions & 0 deletions example.html
@@ -0,0 +1,51 @@
<html>
<head>
<!-- include stylesheet -->
<link type="text/css" rel="stylesheet" href="jquery.fileManager.css" />

<!-- include required jQuery + jQueryUI -->
<link type="text/css" rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1/themes/redmond/jquery-ui.css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>

<script type="text/javascript" src="jquery.fileManager.js"></script>
</head>

<body>
<h1>jQuery.fileManager</h1>

<h2>Simple</h2>
<!-- create the container -->
<div id="filemanager"></div>

<!-- initialise the script, passing the path to the php script -->
<script type="text/javascript">
$('#filemanager').fileManager({ajaxPath:'fileManager.php'});
</script>


<h2>Simple with upload</h2>
<div id="filemanager_upload"></div>
<script type="text/javascript">
$('#filemanager_upload').fileManager({ajaxPath:'fileManager.php',upload:true});
</script>


<h2>Simple with events</h2>
<div id="filemanager_events"></div>
<script type="text/javascript">
$('#filemanager_events').fileManager({
ajaxPath:'fileManager.php',
upload:true,
events:{
click: function() {
var data = $(this).data();
alert(data.item.title + ' = ' + data.item.fullPath);
}
}
});
</script>


</body>
</html>
4 changes: 4 additions & 0 deletions jquery.fileManager.js
Expand Up @@ -47,6 +47,10 @@
this.each(function () { // swap with getJSON so not duplicating ajax
var $sel = $(this);
$.ajax({url:mbOptions.ajaxPath,dataType:'json',type:'POST',data:query,success:function(data, status) {
if (!data) {
$sel.append('No data received. Please ensure ProcessAjax is called in your ajax script.');
return;
}
$sel.data('result',data);
$sel.data('options',mbOptions);
if (status != "success") {
Expand Down

0 comments on commit bdc1740

Please sign in to comment.