drq231358 2012-03-02 23:52
浏览 29
已采纳

AJAX(JQuery)意外地返回错误

I have this Jquery AJAX request to process the creation of Word documents (using PHPWord). The reports are processed and, as far as I am aware, I should not get an error. Whilst the reports are processed, I cannot get the 'data' response from the page, which returns the processed file's name which is needed to provide download links.

The AJAX request looks like this (it is based upon list items with the class 'selected'):

$('.selectionList.unprocessed li.selected').each(function(index) {
    params = 'reportNo=' + ($(this).index() + 1);
    $.ajax({
        url: 'word/export.php',
        data: params,
        dataType: 'script',
        type: 'post',
        success: function(data) { 
            increaseProgressBar();
        },
        error: function(jqXHR, textStatus, errorThrown) {
            increaseProgressBar(); 
            alert('failure ' + textStatus + ' and ' + errorThrown); 
        }
    });
});

increaseProgressBar() just increases the width of the coloured part of a progress bar.

The errors I get in the alert boxes are either:

failure parsererror and SyntaxError: Unexpected identifier

or (both are received seemingly randomly)

failure parsererror and SyntaxError: Unexpected identifier

I attempted to post to this page using a form and that worked fine and the page echoed the correct response.

  • 写回答

1条回答 默认 最新

  • dougang5993 2012-03-05 18:29
    关注

    Very simple solution - I just need to change the dataType from script to text and the rest of it works fine.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历