Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
Can';无法使用基本的AJAX脚本,这是jQuery和Javascript的新手_Jquery_Ajax - Fatal编程技术网

Can';无法使用基本的AJAX脚本,这是jQuery和Javascript的新手

Can';无法使用基本的AJAX脚本,这是jQuery和Javascript的新手,jquery,ajax,Jquery,Ajax,正在尝试使此AJAX请求正常工作。任何主体部分都会隐藏,就像我在事件处理程序后的第一行所说的那样。但是,about.html中的内容没有加载,我没有收到任何错误消息。有什么想法吗 $(document).ready(function() { //AJAX About.html $('#about-button').on('click', function() { $('body section').hide(), $.ajax

正在尝试使此AJAX请求正常工作。任何主体部分都会隐藏,就像我在事件处理程序后的第一行所说的那样。但是,about.html中的内容没有加载,我没有收到任何错误消息。有什么想法吗

    $(document).ready(function() {


      //AJAX About.html
      $('#about-button').on('click', function() {
        $('body section').hide(),

        $.ajax('about.html'), {
          success: function(response) {
            $('.about-page').html(response).slideDown()
          },
          error: function(request, errorType, errorMessage) {
            $('body').html("<p> 'Error: ' + errorType + ' with message ' + errorMessage </p>")
          },
          timeout: 3000
        };
      });



    });
$(文档).ready(函数(){
//AJAX About.html
$(“#关于按钮”)。在('click',function()上{
$('body section').hide(),
$.ajax('about.html'){
成功:功能(响应){
$('.about page').html(响应).slideDown()
},
错误:函数(请求、错误类型、错误消息){
$('body').html(“'错误:'+errorType+'带消息'+errorMessage

”) }, 超时:3000 }; }); });
您的语法不正确。您过早地关闭了
$.ajax()
的参数,因此没有将对象传递给它

与此相反:

   $.ajax('about.html'), {
      success: function(response) {
        $('.about-page').html(response).slideDown()
      },
      error: function(request, errorType, errorMessage) {
        $('body').html("<p> 'Error: ' + errorType + ' with message ' + errorMessage </p>")
      },
      timeout: 3000
    };

谢谢你的帮助!
   $.ajax('about.html', {
      success: function(response) {
        $('.about-page').html(response).slideDown();
      },
      error: function(request, errorType, errorMessage) {
        $('body').html("<p> 'Error: ' + errorType + ' with message ' + errorMessage </p>");
      },
      timeout: 3000
   });