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 1056961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:47:34+00:00 2026-05-16T17:47:34+00:00

Am I missing something? I’m trying to do a simple ajax call using jquery

  • 0

Am I missing something? I’m trying to do a simple ajax call using jquery to a web service on my site and I get a 500 error every time when I make the call from the master page. Has no one ever made an ajax call from a master page or am I just crazy and extremely deprived of sleep?

Example:

MasterPage.master

<script type="text/javascript">
    $(document).ready(function () {
        $.ajaxSetup({ dataType: "json", contentType: "application/json; charset=utf-8" });

        $.ajax({
            url: '<%= ResolveUrl("~/Services/Test.asmx/HelloWorld") %>',
            success: function (data) {
                alert(data);
            },
            error: function (xhr, err) {
                alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
                alert("responseText: " + xhr.responseText);
            }
        });

    });
</script>

/Services/Test.asmx

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

See anything wrong? Do I have a misunderstanding of the Master Page? Please help!

  • 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-05-16T17:47:35+00:00Added an answer on May 16, 2026 at 5:47 pm

    Ok, I believe I have figured out the problem. Now I’m beginning to think I am just sleepy. A couple of issues that I had and I’ll list them for everyone else to make sure they DON’T do in the future:

    1) I remember reading another post previously that explained that an ajax call via the jQuery library does not like a null object for data so something has to be listed even if it’s an empty array. So, that’s exactly what I added:

    $.ajax({
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                type: 'POST',
                data: [],
                url: '<%= ResolveUrl("~/Test.asmx/HelloWorld") %>',
                success: function (data) {
                    alert(data);
                },
                error: function (xhr, err) {
                    //alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
                    //alert("responseText: " + xhr.responseText);
                    $('#ajaxResponse').html(xhr.responseText);
                }
            });
    

    2) Once I got past the jQuery ajax problem, I was then presented an error message from the web service itself. Warned me that to be able to call the web service from a script, I have to add 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 Test
        Inherits System.Web.Services.WebService
    
        <WebMethod()> _
        Public Function HelloWorld() As String
            Return "[{""Hello World""}]"
        End Function
    
    End Class
    

    This solved it and now I can call it wherever it resides. Thanks for the posts but looks like I was just overlooking things as usual…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I must be missing something obvious, but still... I get MySQL ERROR 1064 (42000)
Am I missing something? Why would I get this error? Expected ) before CLLocationDegress.
I know I am missing something simple, but I can't get this redirect to
I am abviously missing something, but I keep getting this message when trying to
Maybe im missing something but im not sure. All im simply trying to do
Either I am missing something or not understanding other posts/instructions. I am trying to
I'm probably missing something simple, but I'm tired of fighting with it. There seem
Perhaps I am missing something simple. I added a modal segue from a button
I must be missing something simple here, but I'm having trouble retrieving data from
I am probably missing something very simple, but here is the situation: I have

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.