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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:41:52+00:00 2026-06-16T13:41:52+00:00

I am new to web service. In my project, I connected Web Service(everything is

  • 0

I am new to web service. In my project, I connected Web Service(everything is ready-made) now when I tried to run I got the below error.

ERROR –>

Uncaught SyntaxError: Unexpected token <

The Web service and my page are in same solution but different projects.

The related code is as follows:

jQuery (URL: 11761)

 function GetAllCategories() {
   $.ajax({
      url: "http://localhost:12015/myWebService.asmx?op=GetCategories",
      type: "POST",
      dataType: "jsonp",
      data: "{}",
      contentType: "application/jsonp; charset=utf-8",
      success: function (data) {
          var categories = data.d;
          $.each(categories, function (index, category) {
              alert(category.CategoryId);
          });
      },
      error: function (e) {
          alert(e.message);
      }
   });
}

Web Service (URL: 12015)

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Categories>  GetCategories()
{
    //Code
}

Before asking here I have gone through this link(cant understand it)

EDIT:

Got alternative answer from this post.

  • 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-16T13:41:52+00:00Added an answer on June 16, 2026 at 1:41 pm

    Figured it out your breaking the Same origin policy as your site and web service are running in two different projects.

    Move the Webservice and website into the same project and it should work.

    Also your javascript is wrong it should be

    function GetAllCategories() {
       $.ajax({
          url: "http://localhost:12015/myWebService.asmx/GetCategories",
          type: "POST",
          dataType: "jsonp",
          data: "{}",
          contentType: "application/jsonp; charset=utf-8",
          success: function (data) {
              var categories = data.d;
              $.each(categories, function (index, category) {
                  alert(category.CategoryId);
              });
          },
          error: function (e) {
              alert(e.message);
          }
       });
    }
    

    the op bit is only there for testing in a web browser. Remove that and you should be good.

    PS @andyb in fairness suggested this answer a while ago but it wasn’t clear that this was the problem!
    UPDATE

    Been doing a bit off jiggery pokery around this today and I’ve clarified a few points that I thought I’d share. you have to POST to an .asmx service and you cannot do this cross domain. You could fire a GET across domains but not a POST so this is the route issue I believe.

    You can enable GET, see How to call an ASMX web service via GET?. But this seems like a bad idea as it would expose your webservice to all and sundry!

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

Sidebar

Related Questions

I am getting below error for my spring based dynamic web project.I am new
I am working on a web service project using gsoap. I am new to
I'm pretty new to Web Services in java. I was starting on a project
Every new web service you create using visual studio comes with a predefined namespace
we are implementing a new web service. The web service will be a store
I want to look at the sources of the New Web Service Client (from
I'm completely new in web service. I want to study about it and the
I am new to Java web service and need to be familiar with REST
I am new to java based web service. I am able to create web
i am using web service asmx, whenever a new request comes, all objects will

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.