Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
ASP.NET VB WebService request with AJAX 500 error

I'm trying to run an AJAX Webservice request on a VB ASP.NET page.

When the page loads, I'm trying to call the webservice but I get a 500 error in the console.

My WebService file looks like this:

<System.Web.Script.Services.ScriptService()>
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")>
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<ToolboxItem(False)>
Public Class usrDataSave
    Inherits System.Web.Services.WebService
    <WebMethod()>
    Public Function saydata(abc As String)
        MsgBox(abc)
        Return abc

    End Function

My ASP.NET page looks like this:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script> 
    <script type="text/javascript">  
    $(document).ready(function() {  
        $.ajax({  
            type: "POST",  
            url: "usrDataSave.asmx/saydata",
            data: "hello_world",  
            contentType: "application/json",  
            datatype: "json",  
            success: function(responseFromServer) {  
                alert(responseFromServer.d)  
            }  
        });  
    });  
    </script> 

    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
</body>
</html>

I expect the page to load and a message box to popup server side that says 'hello_world' as well as the web browser to create a popup that says the same. However, this does not happen as I get a 500 error instead.

I've tried to fix this by using different versions of jQuery as well as enabling requests in the web.config file like this:

 <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>

This doesn't work and I still get that "the server responded with a status of 500" in the web browser console. No errors are logged within the application's debug console.

How can I fix this?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda