AJAX调用后,PHP函数函数、AJAX、PHP

2023-09-12 21:16:44 作者:哥 不帅但很坏,

当用户提交表单上我的网页我使用AJAX而无需刷新页面提交信息。在用户提交的信息,我想运行,我已经写了显示信息的PHP函数。这是可能的还是我需要运行其他的AJAX功能后,

更新

  $(函数(){
       $('加')。在('提交',函数(E){
          $阿贾克斯({
            类型:'后',
            网址:submit.php,
            数据:$('本')序列化()。
            成功:函数(){
              警报(形式提交);
            }
          });
          即preventDefault();
          updateWords(); // PHP函数
        });
      });
 

解决方案 php调用mysql加密函数 php连接mySql,加密函数

您将需要运行在第一个成功的另一个AJAX调用。

JavaScript不能用PHP直接交互,因此,你不能调用从AJAX调用成功/完整功能的PHP函数。

When a user submits the form on my page I use AJAX to submit the information without refreshing the page. After the user submits the information I want to run a PHP function that I have already written that displays the information. Is this possible or do I need to run another ajax function to update after

    $(function () {
       $('add').on('submit', function (e) {
          $.ajax({
            type: 'post',
            url: 'submit.php',
            data: $('this').serialize(),
            success: function () {
              alert('form was submitted');
            }
          });
          e.preventDefault();
          updateWords(); //PHP FUNCTION
        });
      });

解决方案

You will need to run another AJAX call on success of the first one.

JavaScript cannot interact with PHP directly and therefore you can't call a PHP function from the success/complete function of the AJAX call.