为什么Ajax的脚本是不是在IIS 7.5赢2008 R2服务器上运行? [英] Why the Ajax script is not running on IIS 7.5 Win 2008 R2 server?

查看:182
本文介绍了为什么Ajax的脚本是不是在IIS 7.5赢2008 R2服务器上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,工作正常,在VS 2013我的开发服务器上,但一旦我出版了它的IIS 7.5的2008 R2服务器上的Ajax脚本,位于我的自定义脚本文件,不工作了,虽然其他JQuery的脚本不叫阿贾克斯都正常工作。是否有需要做,才能有阿贾克斯的服务器工作什么吗?我读过一些职位,但无法找到答案。我限制在IIS和Ajax的经验。

//更新:

我已经想通了,Ajax的脚本工作,而这个问题是最有可能在以下行:

URL:/首页/ GetRates',// URL的请求

使用我发现的GetRates()函数没有被调用的远程服务器中的debuger,虽然它是在本地(在VS 2013)开发服务器。我看到的是路径,但不唯一的区别知道如何解决它。 下面是Ajax的脚本:

  //获取率和更新局部视图
$(函数(){
    $('#reservSearch)。递交(函数(){
        如果($(本).valid()){
            $(#theModal)模式(显示)。 //显示进行中.....
            $阿贾克斯({
                网址:/首页/ GetRates',// URL的请求
                数据:$(#reservSearch)序列(),//要发送的数据(将被转换为一个查询字符串)。
                类型:POST,//这是否是一个POST或GET请求
                数据类型:HTML,//我们预计回的数据类型
                成功:功能(数据){// code到如果请求成功运行;响应被传递给函数
                    $(#theModal)模式(隐藏)。 //关闭进行模态.....
                    $('#ratesView')的HTML(数据)。 //填充DIV与结果
                },
                错误:函数(XHR,状态){// code到如果请求失败运行;原始请求和状态codeS被传递给功能
                    $(#theModal)模式(隐藏)。 //关闭进行模态.....
                    警报('错误:检索停车费+< / BR>中+ xhr.error);
                }
            });
        }
// //,以便取消默认提交表单并执行AJAX调用返回false是很重要的
        返回false;
    });
});
 

//第二次更新

下面的注释部分的指示后,这是从Ajax调用的响应:

 < D​​IV ID =头>< H1>在应用默认Web站点和其中的服务器错误; / H1>< / DIV>
< D​​IV ID =SERVER_VERSION>< P>互联网信息服务7.5 LT; / P>< / DIV>
< D​​IV ID =内容>
< D​​IV CLASS =内容的容器>
 <字段集><传奇>错误总结< /传说>
  < H2> HTTP错误404.0  - 找不到< / H>
  < H3>您正在寻找已被删除的资源,有其名称更改,或者暂时不可用< / H3>
 < /字段集>
< / DIV>
< D​​IV CLASS =内容的容器>
 <字段集><传奇>详细的错误信息和LT; /传说>
  < D​​IV ID =细节遗>
   <表格边框=0的cellpadding =0CELLSPACING =0>
    < TR类=ALT><第i个模块< /第i;< TD> IIS Web核心< / TD>< / TR>
    < TR><第i个;通知< /第i;< TD>麻prequestHandler< / TD>< / TR>
    &所述; TR类=ALT>&其中;第i个处理程序&所述; /第i;&其中; TD> StaticFile&所述; / TD>&所述; / TR>
    < TR><第i个错误$ C $℃下/次>< TD> 0x80070002< / TD>< / TR>

   < /表>
  < / DIV>
  < D​​IV ID =细节 - 右>
   <表格边框=0的cellpadding =0CELLSPACING =0>
    < TR类=ALT><第i个请求的URL< /第i;< TD>的http://本地主机:80 /主页/ GetRates< / TD>< / TR>
    < TR><第i个物理路径< /第i;< TD> C:\的Inetpub \ wwwroot的\首页\ GetRates< / TD>< / TR>
    < TR类=ALT><第i个登录方法< /第i;< TD>匿名< / TD>< / TR>
    < TR><第i个登录用户< /第i;< TD>匿名< / TD>< / TR>

   < /表>
   < D​​IV CLASS =清除>< / DIV>
  < / DIV>
 < /字段集>
< / DIV>
< D​​IV CLASS =内容的容器>
 <字段集><传奇>最可能的原因:其中; /传说>
  < UL> <李>中指定的Web服务器上不存在的目录或文件< /李> <李>在URL中包含拼写错误< /李> <李>在自定义过滤器或模块(如URLScan),限制对该文件的访问< /李> < / UL>
 < /字段集>
< / DIV>
< D​​IV CLASS =内容的容器>
 <字段集><传奇>您可以尝试的东西:< /传说>
  < UL> <李>创建Web服务器上的内容< /李> <李>检查浏览器URL< /李> <李>创建跟踪规则以跟踪失败请求,该HTTP状态code和查看是哪个模块在调用SetStatus。有关创建跟踪规则为失败的请求的详细信息,请单击< A HREF =htt​​p://go.microsoft.com/fwlink/?LinkID=66439>此处< / a取代。 < /李> < / UL>
 < /字段集>
< / DIV>


< D​​IV CLASS =内容的容器>
 <字段集><传奇>链接和更多信息< /传说>
  此错误意味着该文件或目录不存在于服务器上。创建文件或目录并重新尝试请求。
  < P>< A HREF =htt​​p://go.microsoft.com/fwlink/?LinkID=62293&IIS70Error=404,0,0x80070002,7601>查看更多资讯,以及RAQUO;< / a取代;&所述; / P>

 < /字段集>
< / DIV>
< / DIV>
< /身体GT;
< / HTML>
 

解决方案

完整的答案是横跨在OP的​​问题的意见US $ p $垫,但我认为这一个帮助最:

  
      
  1. 进入该网页,这使得AJAX调用
  2.   
  3. 在浏览器preSS F12
  4.   
  5. 转到网络标签
  6.   
  7. 启动AJAX调用通过提交表单#reservSearch
  8.   
  9. 在网络选项卡中寻找一个电话到/ home / GetRates
  10.   
  11. 点击它
  12.   
  13. 检查preVIEW和Response选项卡中查看输出从您的服务器
  14.   
  15. 是它显示,您的AJAX调用被监听?
  16. 预期的HTML数据   

I have a web app that works fine on VS 2013 on my development server, but once I published it on the IIS 7.5 2008 R2 server the Ajax scripts, located on my custom script file, don't work anymore, although the other JQuery scripts that do not call Ajax do work properly. Is there anything else that needs to be done in order to have ajax working in the server? I've read some posts about, but couldn't find an answer yet. I've limited experience in IIS and Ajax.

// Update:

I've already figured out that the Ajax script works and that the problem is most likely in the following line:

"url: '/Home/GetRates', // URL for the request"

Using the debuger I found out that the GetRates() function is not been called in the Remote Server, although it is in the local (Under VS 2013) development server. The only difference that I see is the path, but dont know how to fix it. Below is the Ajax script:

// Retrieve rates and update partial view
$(function () {
    $('#reservSearch').submit(function () {
        if ($(this).valid()) {
            $("#theModal").modal("show");              // Display the in progress.....
            $.ajax({
                url: '/Home/GetRates',                 // URL for the request 
                data: $("#reservSearch").serialize(),  // the data to send (will be converted to a query string)
                type: "POST",                          // whether this is a POST or GET request  
                dataType: 'html',                      // the type of data we expect back   
                success: function (data) {             // code to run if the request succeeds; The response is passed to the function
                    $("#theModal").modal("hide");      // Close the in progress modal.....
                    $('#ratesView').html(data);        // Fill div with results
                },
                error: function (xhr, status) {        // code to run if the request fails; the raw request and status codes are passed to the function
                    $("#theModal").modal("hide");      // Close the in progress modal.....
                    alert('Error: Retrieving parking rates' + "</br>" + xhr.error);
                }
            });
        }
//        // it is important to return false in order to cancel the default submission of the form and perform the AJAX call
        return false;
    });
});

// SECOND UPDATE

After following the directions in the comment section, this is the response from the ajax call:

    <div id="header"><h1>Server Error in Application "DEFAULT WEB SITE"</h1></div> 
<div id="server_version"><p>Internet Information Services 7.5</p></div> 
<div id="content"> 
<div class="content-container"> 
 <fieldset><legend>Error Summary</legend> 
  <h2>HTTP Error 404.0 - Not Found</h2> 
  <h3>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h3> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><legend>Detailed Error Information</legend> 
  <div id="details-left"> 
   <table border="0" cellpadding="0" cellspacing="0"> 
    <tr class="alt"><th>Module</th><td>IIS Web Core</td></tr> 
    <tr><th>Notification</th><td>MapRequestHandler</td></tr> 
    <tr class="alt"><th>Handler</th><td>StaticFile</td></tr> 
    <tr><th>Error Code</th><td>0x80070002</td></tr> 

   </table> 
  </div> 
  <div id="details-right"> 
   <table border="0" cellpadding="0" cellspacing="0"> 
    <tr class="alt"><th>Requested URL</th><td>http://localhost:80/Home/GetRates</td></tr> 
    <tr><th>Physical Path</th><td>C:\inetpub\wwwroot\Home\GetRates</td></tr> 
    <tr class="alt"><th>Logon Method</th><td>Anonymous</td></tr> 
    <tr><th>Logon User</th><td>Anonymous</td></tr> 

   </table> 
   <div class="clear"></div> 
  </div> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><legend>Most likely causes:</legend> 
  <ul>  <li>The directory or file specified does not exist on the Web server.</li>  <li>The URL contains a typographical error.</li>    <li>A custom filter or module, such as URLScan, restricts access to the file.</li> </ul> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><legend>Things you can try:</legend> 
  <ul>  <li>Create the content on the Web server.</li>  <li>Review the browser URL.</li>    <li>Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
 </fieldset> 
</div> 


<div class="content-container"> 
 <fieldset><legend>Links and More Information</legend> 
  This error means that the file or directory does not exist on the server. Create the file or directory and try the request again. 
  <p><a href="http://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=404,0,0x80070002,7601">View more information &raquo;</a></p> 

 </fieldset> 
</div> 
</div> 
</body> 
</html> 

解决方案

The full answer is spread across the comments on OP's question but I think this one helped the most:

  1. Go to the web page which makes the AJAX call
  2. In Chrome press F12
  3. Go to the Network tab
  4. Activate the AJAX call by submitting the form #reservSearch
  5. In the Network tab look for a call to /Home/GetRates
  6. Click it
  7. Check the Preview and Response tabs to see the output from your server
  8. Is it displaying the expected HTML data which your AJAX call is listening for?

这篇关于为什么Ajax的脚本是不是在IIS 7.5赢2008 R2服务器上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆