VB NET JQUERY AJAX上的错误500

时间:2016-05-16 15:41:09

标签: javascript jquery asp.net ajax vb.net

我在jquery ajax的select选项中尝试列表,但我需要帮助!

这是错误

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="panel-slide-left">
  <div style="clear:both;"></div>
  <div class="columns">
    <div class="colcenter">
      <div class="checkbox">
        <label>
          <input type="checkbox" value="">
          <h5>Broadcast Language English</h5>
        </label>
      </div>
      <div class="checkbox">
        <label>
          <input type="checkbox" value="">
          <h5>Stream Language English</h5>
        </label>
      </div>
    </div>
  </div>
  <div style="clear:both;"></div>
</div>
<a class="trigger-left" href="#">X</a>

<div class="panel-slide-right">
  <div style="clear:both;"></div>
  <div class="columns">
    <div class="colcenter">
      <div class="checkbox">
        <label>
          <input type="checkbox" value="">
          <h5>Broadcast Language English</h5>
        </label>
      </div>
      <div class="checkbox">
        <label>
          <input type="checkbox" value="">
          <h5>Stream Language English</h5>
        </label>
      </div>
    </div>
  </div>
  <div style="clear:both;">
  </div>
  <a class="trigger-right" href="#">X</a>

我的代码

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:20440/admin/cadastro.aspx/GetMarcas

我的控制器

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <meta charset="utf-8" />
    <title></title>
    <link href="../assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../assets/css/font-awesome.min.css" rel="stylesheet" />
    <link href="../assets/css/estilo.css" rel="stylesheet" />
    <script src="../assets/js/jquery-1.9.1.min.js"></script>
    <script src="../assets/js/bootstrap.min.js"></script>
    <script type="text/javascript">



  $(document).ready(function () {
        $.ajax({


type: "POST",
            contentType: "application/json; charset=UTF-8",
            url: "cadastro.aspx/GetMarcas",
            data: "{}",
            dataType: "json",
            success: function (result) {


$('#marca').empty();
                $('#marca').append("<option value='0'>--Select--</option>");
                $.each(result.d, function (key, value) {
                    $("#marca").append($("<option></option>").val(value.Codigo).html(value.Descricao));
                });
            }
        });
    });
</script>

</head>
<body>
<nav class="navbar navbar-inverse navbar-static-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="index.aspx">DASHBOARD <i class="fa fa-bar-chart"></i></a></li>
                <li><a href="cadastro.aspx">CADASTRO <i class="fa fa-plus-circle"></i></a></li>
                <li><a href="listagem.aspx">ITEMS CADASTRADOS <i class="fa fa-eye"></i></a></li>
            </ul>

        </div>
    </div>
</nav>
<div class="container">
    <div class="col-md-12">



        <form action="/" method="post">
            <div class="col-md-4">
                <label>Marca</label>
                <select class="form-control" name="marca" id="marca" runat="server">
                 </select>
            </div>
            <div class="col-md-4">
                <label>Modelo</label>
                <select class="form-control" name="modelo" id="modelo" runat="server">
                    <option value="value">text</option>
                </select>
            </div>
            <div class="col-md-4">
                <label>Cor</label>
                <select class="form-control" name="cor" id="cor" runat="server">
                    <option value="value">text</option>
                </select>
            </div>

            <div class="col-md-4">
                <label>Ano</label>
                <input type="text" name="ano" id="ano" class="form-control" />
            </div>

            <div class="col-md-4">
                <label>Placa</label>
                <input type="text" name="placa" id="placa" class="form-control" />
            </div>
        </form>
    </div>
</div>

我没有使用方法回发,我需要有关此错误的帮助,以便从数据库中选择列表数据。

1 个答案:

答案 0 :(得分:0)

本文对jQuery / Webforms集成有很大帮助:

http://www.codeproject.com/Articles/95525/ASP-NET-and-jQuery-to-the-Max

首先要检查的是,如果通过在GetMarcas方法中添加断点来到达服务器端。如果你到达它,你将能够在方法中调试你的方式,并获得有关错误的更多信息。

查看代码,它可能与您发送初始化命令的字符串参数一样简单。我的猜测是你要调用一个名为sp_ListaMarcas的存储过程。如果是这样,您不需要exec部分。你应该这样做:

Using cmd As New SqlCommand("sp_ListaMarcas", con)