Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php JQuery.ajax()方法未执行_Php_Javascript_Jquery_Web Applications - Fatal编程技术网

Php JQuery.ajax()方法未执行

Php JQuery.ajax()方法未执行,php,javascript,jquery,web-applications,Php,Javascript,Jquery,Web Applications,我有一个按钮,可以调用如下所示的JavaScript方法: processSelection = function(filename) { //alert('method reached'); $.ajax({ url: "sec/selectUsers.php", data: "filename="+filename, cache: false, dataType:'html', success: function(dat

我有一个按钮,可以调用如下所示的JavaScript方法:

processSelection = function(filename) {
  //alert('method reached');
   $.ajax({
      url: "sec/selectUsers.php",
      data: "filename="+filename,
      cache: false,
      dataType:'html',

      success: function(data) {
        //$('#uploader').html(data);
        $('#noUsers').sortOptions();
        values = $('#noUsers').children();

        for (i = 0; i < values.length; i++) {
          $(values[i]).bind('dblclick',switchUser); 
        }

        $('#addButton').bind('click',addSelection);
        $('#removeButton').bind('click',removeSelection);
        $('#submitButton').bind('click',addUsersToFile);
      },

      error: function (request, textStatus, errorThrown) {
          alert('script error, please reload and retry'); 
      }

   }); /* ajax */
}
好,

为了简化我的问题,我做了以下工作:

processSelection = function(){
              //alert('method reached');
               $.ajax({
                          url: "sec/testPage.php",
                          cache: false,
                          success: function() {
                                              alert('success');
                          },
                          dataType:'html',
                          error: function (request, textStatus, errorThrown) {
                              alert('script error, please reload and retry'); }
                     });
}

其中testPage.php只是一个表,其中包含一些值

现在,当我单击按钮时,它会显示“success”,但不会显示testPage.php

dataType: 'HTML' 
据我所知,在你成功之前,必须有一种方法。如果仍然无法工作,请尝试以下操作:

它不会显示测试页面,因为您没有在当前正文中添加任何内容。如果在屏幕上看到“success”,脚本将成功执行。您需要做的就是,如果您在测试页面中生成了html,将所有html分配给一个php变量,然后只回显它,而不是像这样返回它

 echo $myhtmlgenerated 
改变

 success: function() { ....


或者您可以使用它并指定一个特殊的div来保存该页面的内容。

是否检查该函数是否正在启动?发布您的按钮
HTML
。尝试使用
url:“/sec/selectUsers.php”
而不是
url:“sec/selectUsers.php”
您使用的url是否正确?PHP文件是否在执行此javascript的页面的子目录“sec”中?所有浏览器都可以通过点击F12查看网络请求和响应。按钮的外观如何,以及如何处理数据。如果取消对警报的注释,则会收到警报。使用firebug查看chrome或Firefox,如果调用php,请查看控制台和NET选项卡
 success: function() { ....
 success: function(result) { 
   $(body).append(result);
 }