Note that there are some explanatory texts on larger screens.

plurals
  1. POFirebug Double console.log messages
    primarykey
    data
    text
    <p>I'm creating a class to create and delete folders and some other things I still have to work on. I'm doing this via ajax. And it works fine. But I get the same message in the console twice. </p> <p>Why is that? Am I doing something wrong? </p> <p>Here is my code till now (also available at <a href="http://snippi.com/s/3sfsfvm" rel="nofollow">http://snippi.com/s/3sfsfvm</a>):</p> <pre><code>&lt;?php //process.php if(!empty($_POST['foldddername'])) { require_once 'test.php'; $folder = new folder; $path = dirname( __FILE__ ); $foldername = strip_tags($_POST['foldddername']); // $folder -&gt;crtFolder($foldername,$path); if($message = $folder -&gt;crtFolder($foldername,$path)) { echo $message; } } ?&gt; &lt;?php //test.php class folder { public function crtFolder($foldername,$path){ $dirpath = $path."\\".$foldername; if ((!is_dir($dirpath))) { if(mkdir($dirpath,0777,true)) { $error = false; $message['error'] = false; $message['message'] = "Folder Created"; return json_encode($message); } else { $error = true; $message['error'] = true; $message['message'] = "Folder Failed To Create"; return json_encode($message); } } else { $error = true; $message['error'] = true; $message['message'] = "Folder Already Exists"; return json_encode($message); } } } ?&gt; //Ajax handling $(function(){ $('.submittt').click(function(){ if($('input.folder-name').val() == "") { console.log('Please enter Folder Name'); return false; } else { $.ajax ({ type: 'POST', url: 'process.php', dataType: 'json', data: { foldddername: $('input.folder-name').val() }, success:function(data) { console.log(data.message); if(data.error === true) { console.log(data.message); } else { console.log(data.message); } }, error:function(XMLHttpRequest,textStatus,errorThrown) { console.log(data.message); } }); return false; } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload