JavaScript AJAX

Status
Not open for further replies.

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
Hey guys, Berk here.
So doing a task system with percent system and so, when you click 'add 10 percents' it should run an ajax request. So it runs but it delays so much, and does not run PNotify.
AJAX code:
Code:
$(document).ready(function(){
    var id = $('#id').text();

    $.ajax({

       url: 'system/js/tasks/addpercent.php',
       method: 'POST',
      }).done(function(res) {
       new PNotify({
          title:'Done',
          type:'success',
          text:'Success'
       });
     }).fail(function(res) {
        console.log(res);
     });
        });
I'm not sure what I'm doing wrong?

Thanks.
 

MayoMayn

BestDev
Oct 18, 2016
1,423
683
Hey guys, Berk here.
So doing a task system with percent system and so, when you click 'add 10 percents' it should run an ajax request. So it runs but it delays so much, and does not run PNotify.
AJAX code:
Code:
$(document).ready(function(){
    var id = $('#id').text();

    $.ajax({

       url: 'system/js/tasks/addpercent.php',
       method: 'POST',
      }).done(function(res) {
       new PNotify({
          title:'Done',
          type:'success',
          text:'Success'
       });
     }).fail(function(res) {
        console.log(res);
     });
        });
I'm not sure what I'm doing wrong?

Thanks.
Currently it only runs the ajax request when the DOM is loaded.
 

Berk

berkibap#4233
Developer
Oct 17, 2015
863
190
Oh, I'm such a dumb. Thanks for reminding :D
 
Mhm, it still does not run the new PNotify({); command.
Files loaded like this:
task_tools.js is where above code is .
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Oh, I'm such a dumb. Thanks for reminding :D
 
Mhm, it still does not run the new PNotify({); command.
Files loaded like this:
task_tools.js is where above code is .
I feel I need to ask, but are the files in the correct directory, and correctly linked in your HTML code?
 
Status
Not open for further replies.

Users who are viewing this thread

Top