duanlie1298 2015-06-05 05:50
浏览 59
已采纳

AJAX不在服务器上传递变量(任何AJAX)

So i have a lot of AJAX functions, they worked all well all good in server as well as in localhost until recently i made some changes in the js files and some ajax-php files as well. Nevertheless...they are still working absolutely fine on localhost...but not on server

During debugging, i found out...that the ajax has no problem getting the file....i mean there is no 404 error....however....it isn't passing the variable...

JS FILE

function nextImg(Imgkey){
changeImgViewerN = 0;
var currUrl = window.location.href;
var baseUrl = currUrl.split(/[\\/]/).pop();
var splitUrl = baseUrl.split('&');
var folderKey = splitUrl.pop();
var groupKey = splitUrl[0];
if(groupKey == undefined) groupKey = folderKey;
   $.ajax({
      url:'/9712d9c1_2be4d8c9318e69_1b526557b8_sF',
      type: 'POST',
      data:{searchNextImg:Imgkey, groupKey:groupKey, folderKey:folderKey},
      success: function(response){
        $('#in_folders').prepend(response);
      }
   })
}

PHP FILE

echo "Here";
if(isset($_POST['searchNextImg']) || isset($_POST['searchPrevImg'])) && isset($_POST['groupKey']) && isset($_POST['folderKey'])){

    echo "Reading";
}

However on the server, it just executes echo "Here"; but not echo "Reading";

My .htaccess file says:

RewriteRule ^9712d9c1_2be4d8c9318e69_1b526557b8_sF$ http://www.example.com/ajaxinc/searchFile.php

There are such other AJAX functions but they are not passing variables to the server, however on localhost, they are working perfectly. All of them.

  • 写回答

3条回答 默认 最新

  • douhuanqiao5290 2015-06-05 05:54
    关注

    replace:

    url:'/9712d9c1_2be4d8c9318e69_1b526557b8_sF',
    

    with

    url:'9712d9c1_2be4d8c9318e69_1b526557b8_sF',
    

    You did not pass this variable searchPrevImg in your ajax call, but that is in or condition so does not matter.
    suggestion:

    use the below way to create data objects:

    data:{'searchNextImg':Imgkey, 'groupKey':groupKey, 'folderKey':folderKey},
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

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