Ajax调用了“无法加载资源:按照500的状态的服务器响应” [英] Ajax call with a 'failed to load resource : the server responded with a status of 500'

查看:1172
本文介绍了Ajax调用了“无法加载资源:按照500的状态的服务器响应”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了做一个AJAX调用一个函数,但我有,当我打电话给我的GetTempData方法,在C#中此错误:

I created a function that do an ajax call but I have this error when I call my GetTempData method in C# :

Failed to load resource: the server responded with a status of 500 (Internal Server Error) 

这是我的code:

function restoreDatas() {
        $.ajax({
            url: "/AddRecipe/GetTempData",
            type: 'GET',
            dataType: 'json',
            contentType: 'application/json',
            cache: false,
            processData: false,
            success: function (result) {

            }
        });
    }

在调用Ajax调用C#方法:

The C# method called by the ajax call :

public ActionResult GetTempData()
    {
        return Json(
        new
        {
            title = Session["title"],
            cookingTime = Session["cookingTime"],
            preparationTime = Session["preparationTime"],
            IngredientList = Session["IngredientList"],
            ingredientsDescription = Session["ingredientsDescription"],
            nbPersons = Session["nbPersons"],
            Category = Session["Category"],
            difficulty = Session["difficulty"],
            nbStars = Session["nbStars"],
            file = Session["file"]
        }, JsonRequestBehavior.AllowGet
            );
    }

我不明白问题出在哪里?

I don't see where is the problem ?

你有什么办法呢?

感谢您

推荐答案

调出开发者工具在浏览器中,并看一看请求/响应。例如,在Chrome preSS F12调出开发者控制台,前往网络标签。尝试再次致电GetTempData方法。您将看到对应于GetTempData请求,并以红色突出显示网络选项卡中的条目。如果你点击,你就可以看到你的请求和响应的详细信息。

Bring up the developer tools in your browser and take a look at the request / response. For example, in Chrome press F12 to bring up the developer console and head to the Network tab. Try calling your GetTempData method again. You will see an entry in the network tab that corresponds to the GetTempData request and is highlighted in red. If you click on that you will be able to see detailed information about your request and response.

心连心

这篇关于Ajax调用了“无法加载资源:按照500的状态的服务器响应”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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