JavaScript No feedback if sql insert succeeded

It's because your ajax success does nothing.

In PHP:

if ($conn->query($sql) === true) {
    echo "Success";
} else {
    echo "Failure";
}

In JS:

 $.ajax({
   type: "POST",
   url: 'test.php',
   data: {action:value},
   dataType: 'text',
   success: function(data) {
       alert(data);
   }
}); 
Answer:1

The last } will not close any code block in your example. the if dont need a === TRUE, just if ($conn->query($sql)), if the query feedback is true the if will be true.

something like this:

    <?
    if(isset($_POST['action']) && $_POST['action'] > 3) {

        $conn = new mysqli($servername, $username, $password, $dbname);
        $values = $_POST['action'];
        $status = 'pending';
        $sql = "INSERT INTO queue (value, status) VALUES ('".$values."', '".$status."')";

        if ($conn->query($sql)) {
            echo 'succes';
        } else { 
            echo 'fail';        
        }                                    
    }       

    ?>

and your js like:

    function myAjax(value) {


      $.ajax({
           type: "POST",
           url: 'test.php',
           data:{action:value},
           dataType: 'text',
           success: function(data) {
                alert(data);
           }

      });
    }
Answer:2

I am using Grid List(dynamic tiles) in angularJS and using <br/> tag but it is not working Here is the code <div ng-controller="gridListDemoCtrl as vm" flex="" ng-cloak="" class="...

I am using Grid List(dynamic tiles) in angularJS and using <br/> tag but it is not working Here is the code <div ng-controller="gridListDemoCtrl as vm" flex="" ng-cloak="" class="...

Okay, I spent all morning trying to solve this, and despite the fact that it seems to have been a problem for a couple years, I couldn't find a solution that worked. I've seen other people on Stack ...

Okay, I spent all morning trying to solve this, and despite the fact that it seems to have been a problem for a couple years, I couldn't find a solution that worked. I've seen other people on Stack ...

  1. allow chrome to remember password

New with JavaScript. Can someone help me understand why calling print() returns undefined? class Quizer { constructor(quizObj) { this.quiz = quizObj; } print() { console....

New with JavaScript. Can someone help me understand why calling print() returns undefined? class Quizer { constructor(quizObj) { this.quiz = quizObj; } print() { console....

  1. javascript class constructor example
  2. javascript class constructor arguments
  3. javascript class constructor array
  4. javascript class constructor async
  5. javascript class constructor super
  6. javascript class constructor with parameters
  7. javascript class constructor function
  8. javascript class constructor overloading
  9. javascript class constructor call method
  10. javascript class constructor not called
  11. javascript class constructor shorthand
  12. javascript class constructor object
  13. javascript class constructor name
  14. javascript class constructor syntax
  15. javascript class constructor es6
  16. javascript class constructor not working
  17. javascript class constructor initialize
  18. javascript class constructor prototype
  19. javascript class constructor spread
  20. javascript class constructor destructuring

I'm inherited an HTML form that uses the js with() function: with (document.images.myImage.style) { left = x + "px"; top = y + "px"; visibility = "visible"; } This code "moves" an ...

I'm inherited an HTML form that uses the js with() function: with (document.images.myImage.style) { left = x + "px"; top = y + "px"; visibility = "visible"; } This code "moves" an ...

  1. javascript with function parameter
  2. javascript with function
  3. javascript with function scope
  4. javascript function with return
  5. javascript function with return value
  6. javascript function with optional parameters
  7. javascript function with arguments
  8. javascript function with callback
  9. javascript function with array parameter
  10. javascript function with string parameter
  11. javascript function with default parameters
  12. javascript function with multiple parameters
  13. javascript function with variable
  14. javascript function with variable arguments
  15. javascript function with object parameter
  16. javascript function with callback parameter
  17. javascript function with return type
  18. javascript function with default value
  19. javascript function with asterisk
  20. javascript function with parameter default value