Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:28:20+00:00 2026-06-13T16:28:20+00:00

I hate to be posting a question like this on here, but I’m running

  • 0

I hate to be posting a question like this on here, but I’m running out of options for really understanding how this works. In a normal .Net web service, without being configured for JSON or anything, there is the following web method:

<WebMethod()> _
Public Function HelloWorld(ByVal str As Int32) As String
    Return "Hello, World!  str=" & str
End Function

I would like to make a really simple webpage that would just use JS to call this web method, get the value out of it, and print it in an alert() statement. I’m continuing to research the subject on my own, but I am having a very hard time finding a straight answer to this question.

This is about the closest I’ve been able to come (aside from this not actually using the return value):

<html>
<body>
<script type="text/JavaScript">
    <!--
        alert("spam");                                
        $.ajax({
            type: "POST",
            data: "&str=1",
            url: "<HTTP path and filename>.asmx/HelloWorld",
            timeout: 15000,
            cache:false,
            success: function (data) {
                alert("good");
            },
            error: function() {
                alert("bad");
            }
        });
        alert("spam");
    //-->
</script>
</body>
</html>

Again I don’t like posting a question like this on StackOverflow, but I’ve been unable to find a clear, straight answer to this, and I’m very new with JavaScript. Thanks!

EDIT: Throwing a try…catch block around the Ajax call, I get the following message:

$ is not defined
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:28:21+00:00Added an answer on June 13, 2026 at 4:28 pm

    $ is a variable. Your code shows that it’s using the jQuery library, using $ as an alias.

    You have to include the jQuery library if you want to use this code.

    To do so, include this before your code:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
    

    However, if you’re new to javascript, I recommend you first try without jQuery.

    For a great tutorial, I can only show you the best resource I know: MDN.

    If you absolutely want to use jQuery, you have to know that your data parameter is wrong. It does accept a string, but this string isn’t well-formed, it should be this: str=1. Adding another variable would be str=1&foo=2.

    jQuery allows you to put an object instead of a string, this provides some syntactic sugar and is generally the recommended way to go (less error-prone):

    data: {
        str: 1,
        foo: 2
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hate posting this since it's somewhat subjective, but it feels like there's a
I hate asking questions like this - they're so undefined... and undefinable, but here
I hate giving out my code like this but I'm getting some errors about
Hate to post this, but I am googled out and tried many different options
I hate to ask this here, but many people on stackoverflow have talked about
I hate to just post a stack trace here, but I am out of
I hate to post this but I am on a time crunch and need
I hate to be the third person to ask this, but the previous two
I hate starting a post with this but I'm new to Java... I've followed
I hate to sound like terrible newb, but are Widgets separate apps? For instance,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.