Error encountered in referencing a web service (ASP/VB.NET)

I am attempting to utilize a web service within my web application developed in Visual Studio 2012.

Below is the code for my web service:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<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 WebService1
    Inherits System.Web.Services.WebService

    <WebMethod()>
    Public Function HelloWorld() As String
       Return "Hello World"
    End Function

End Class

My web.config configuration:

<system.web>

    <httpHandlers>
      <remove verb="*" path="*.asmx"/>
      <add verb="*" path="*.asmx"
        type="System.Web.Script.Services.ScriptHandlerFactory"
         validate="false"/>
    </httpHandlers>

....

</system.web>

Declared on the site.master

<asp:ScriptManager runat="server">
        <Services>
            <asp:ServiceReference
            path="../WebService1.asmx" />
        </Services>

.....

</asp:ScriptManager>

The call from JavaScript triggered by a button

function provaWebService() {
            alert("entrato")
            WebService1.HelloWorld(onSuccess);
        }

        function onSuccess(result) {
            alert(result)
        }

I'm encountering an error in Firefox console: ReferenceError: WebService1 is not defined

and

ReferenceError: Type is not defined

Can someone provide some assistance?

Answer №1

It seems like you forgot to include the namespace when calling the webservice. Make sure to use the fully qualified name of the class:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transferring Information from a JavaScript Page to an HTML Page without the Use of a Form or URL

I am faced with a challenge in sending a variable from JavaScript to another HTML page and then redirecting to that page. The catch is that I cannot use forms because the first page consists purely of JavaScript and is stored as a .js file, thus ruling out ...

Add Material UI Snackbar to the document's body

I have designed a feature where a component becomes visible only when a user hovers over it. Inside this component, there is a button that allows the user to add something to the local storage. When the button is clicked, the component is removed from the ...

Refreshing the page causes Material UI Button to revert to default styling

My question regarding the Material UI Button losing styling after a page refresh (link: Material UI Button loses Styling after page refresh) went unanswered, so I am reposting with a CodeSandbox included for reference: https://codesandbox.io/s/bold-resonan ...

Controller issue: Post action functioning properly in one controller but malfunctioning in another controller

My current project involves the creation of a new project by users. The user interface includes various textboxes and a submit button, which triggers a POST request to an API endpoint. This API call then adds a new project entity to the database. Recently, ...

Tips for identifying if the function "res.end()" has been executed or not

Is there a method to determine if the res.end function has been triggered? var http = require('http'); http.createServer(function (req, res) { some_function_may_called_end(req, res); // Is there a way to check for this? if(res.is_ended = ...

Is there a way to determine if jQuery lightslider has been initialized, and if so, how can I effectively remove the instance?

Currently, I have integrated the JQuery lightSlider into my project. Despite some code adjustments, it is functioning well. My goal is to dynamically replace the lightSlider content with data returned via AJAX, which I have successfully achieved. After r ...

What is the best way to implement seamless transitions between different components in my code?

I'm currently developing my own single page application and I want the content to have a smooth animation effect as I scroll down, instead of being static. Despite searching for guides on this topic, I haven't found any helpful resources yet. An ...

Creating a Simple "Alert Box" and "Multiplying User Input by 5" with JavaScript

This code features a simple JavaScript function where the user is prompted to enter a number into a text field, which is then multiplied by 5 and displayed in an alert box. However, there seems to be an issue with it not functioning properly. Can anyone pr ...

Vue.js, when using async await functions, sometimes renders blank results

Currently working on a JavaScript project that requires the use of await/async to fetch data from an API. Here is a snippet of my code: const fetchData = async () => { let data = []; for (let i = 0; i < this.data.length; ...

Trouble with triggering a jQuery event on a dynamically generated div

I have a snippet of code that generates dynamic divs with varying content on a webpage. Each of these dynamically created divs includes the class "entry". I am seeking a way to trigger a click event when any of these dynamically generated divs are clicked. ...

Receiving a 401 error when making an Axios post request

Having trouble with a 401 error when making a POST request to an API? Don't worry, I've got some suggestions that might help. I'm able to successfully make GET requests to the same API with a 200 status, so it could be a syntax issue in the ...

How about this: "Effortlessly upload files by simply dragging and dropping them from your computer to

Currently, I am facing a challenge in uploading a picture from my PC to a website that utilizes a drag and drop interface. Despite using Javascript to open the required link, set properties, and click on the upload field, a file manager window appears wh ...

Uploading a file using Selenium WebDriver and jQuery integration

Imagine a webpage containing the following element: <div class="block-title-inside"> <a href="javascript:void(0);" class="block-title-link fright" style="display:block; overflow: hidden; width: 105px;">Upload video <span class="blue-ar ...

jQuery.clone() Internet Explorer issue

I have a scenario where I use jQuery.clone() to extract the html of a page and then append it to a pre tag. Surprisingly, this operation works perfectly fine in Firefox and Chrome, but there's no response when it comes to IE: <!DOCTYPE html> &l ...

Activate the mouseenter event as soon as an animated element makes contact with the cursor

As I venture into the world of web development, I am currently working on creating a game where the main objective is to avoid touching moving circles with the cursor. My approach involved using a mouseenter event as shown in the JSFiddle example below: $ ...

Good day extract a collection of articles

I am trying to parse out the date and full URL from articles. const cheerio = require('cheerio'); const request = require('request'); const resolveRelative = require('resolve-relative-url'); request('https://www.m ...

Finding strikeout text within <s> or <del> tags can be identified by closely examining the HTML codes

The issue arises with the text that reads as follows: 316.6.1 Structures. Structures shall not be constructed This is represented in HTML as: <b> <s> <span style='font-size:10.0pt'>316.6.1 Structures</span> ...

Only grant access to Angular view if user possesses the necessary cookie

How can I restrict access to a view in angular ui-router only if a cookie is active with the user's email address? I am currently setting the cookie in a post request where I assign the cookie value to the user's email address. Now, I want to e ...

How do I restrict the camera's perspective in a Three.js 3D environment?

I recently incorporated first person controls into my three.js scene. I am now seeking a way to restrict the camera views in order to prevent the ends of the scene from being displayed. My implementation utilizes the firstpersoncontrols.js from the three.j ...

What is the best way to use jQuery to print the contents of an HTML input field multiple times?

I have a text input field and a button. When I enter a name in the input field and click the button, it displays the name below the input field. Each time the button is clicked, the next name is added underneath the previous one. Below is the jQuery code: ...