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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:17:17+00:00 2026-05-23T15:17:17+00:00

How do I get error message from webmethod, I want to initiate error. Also,

  • 0

How do I get error message from webmethod, I want to initiate error. Also, I want different error messages for different occasions.

        $.ajax({
            type: "POST",
            url: "betting.aspx/submitFunction",
            data: JSON.stringify({ results: jsonObj, edit: $("#ctl00_ContentPlaceHolder1_CreateOrEdit").val() }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(arg) { //call successfull
                window.location = "bHistory.aspx";
            },
            error: function(xhr) {
                alert("Error! You need to login, and try again");
                window.location = "login.aspx";
                //error occurred
            }
        });
  • 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-23T15:17:18+00:00Added an answer on May 23, 2026 at 3:17 pm

    I’ve faced that problem as well. the issue is that if you throw an exception from your web method, it gets wrapped, like so "Message":"{your message}","StackTrace":" at ...

    what I ended up doing was creating this js function to parse the returned exception.
    it’s pretty ugly, and I’d love to see if anyone’s come up with anything better.

    function getErrorMessage(e) {
        return e.responseText.substring(e.responseText.indexOf("\"Message\":\"") + "\"Message\":\"".length, e.responseText.indexOf("\",\"Stack"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to get error messages from a WF4 workflow back
I get this error message in Eclipse: Access restriction: The type DirectoryWalker is not
I get an error message from Firefox Unresponsive script. This error is due to
I get an error message from GHCi about a duplicate definition for symbol __module_registered,
I'm trying to compile the two files below, but get an error message from
I get this error message when installing SQL 2005 Analysis services. The cabinet File
We're using Maven at work at quite regularly we get the error message The
I installed subclipse in eclipse, but I get an error message Expected format '3'
Yesterday I testet a lot on my device. Suddenly I get this error message
I get the following error message in SQL Server 2005: User '<username>' does not

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.