how do I get the reponse text from ajax / jquery?

后端 未结 3 699
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-02 04:45

Imagine I run this:

     $.ajax({
        type: \'POST\',
        url: \'/ajax/watch.php\',
        data: {\'watch\':\'aukcia\', \'id\':aukciaID},
        co         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-02 05:48

    Use on your client side ajax like this

     $.ajax({
            type: "POST",
            url: "insert-data.php",
            data: 
        {student_name:student_name,student_roll_no:student_roll_no
         ,student_class:student_class},
            dataType: "JSON",
            success: function(data) {
             $("#message").html(data);
            $("p").addClass("alert alert-success");
            },
            error: function(err) {
            alert(err);
            }
        });
    

    in server side after query excecute you may use it give success when you query success false when your query has fault

    if($stmt->execute())
     {
    $res="Data Inserted Successfully:";
     echo json_encode($res);
    }
     else {
     $error="Not Inserted,Some Probelm occur.";
    echo json_encode($error);
      }
    

提交回复
热议问题