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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:14:26+00:00 2026-06-12T04:14:26+00:00

I’ve tried countless examples and cannot get this to work. I’m trying to call

  • 0

I’ve tried countless examples and cannot get this to work.

I’m trying to call a cross domain asp.net web service but get back the following error every time:

jQuery18105929389187970706_1348249020199 was not called

Here’s my web service:

[WebService(Namespace = "http://www.mywebsite.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
[ScriptService]
public class DataService : System.Web.Services.WebService
{
    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public string GetIncidentsByAddress()
    {
        return "It worked!";
    }
}

My HttpModule to handle Json:

 public class JsonHttpModule : IHttpModule
    {
        private const string JSON_CONTENT_TYPE = "application/json; charset=utf-8";

        public void Dispose()
        {
        }

        public void Init(HttpApplication app)
        {
            app.BeginRequest += OnBeginRequest;
            app.ReleaseRequestState += OnReleaseRequestState;
        }

        bool _Apply(HttpRequest request)
        {
            if (!request.Url.AbsolutePath.Contains(".asmx")) return false;
            if ("json" != request.QueryString.Get("format")) return false;
            return true;
        }

        public void OnBeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            if (!_Apply(app.Context.Request)) return;

            // correct content type of request
            if (string.IsNullOrEmpty(app.Context.Request.ContentType))
            {
                app.Context.Request.ContentType = JSON_CONTENT_TYPE;
            }
        }

        public void OnReleaseRequestState(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;

            if (!_Apply(app.Context.Request)) return;

            // apply response filter to conform to JSONP
            app.Context.Response.Filter =
                new JsonResponseFilter(app.Context.Response.Filter, app.Context);
        }
    }

    public class JsonResponseFilter : Stream
    {
        private readonly Stream _responseStream;
        private HttpContext _context;

        public JsonResponseFilter(Stream responseStream, HttpContext context)
        {
            _responseStream = responseStream;
            _context = context;
        }

        //...

        public override void Write(byte[] buffer, int offset, int count)
        {
            var b1 = Encoding.UTF8.GetBytes(
              _context.Request.Params["callback"] + "(");
            _responseStream.Write(b1, 0, b1.Length);
            _responseStream.Write(buffer, offset, count);
            var b2 = Encoding.UTF8.GetBytes(");");
            _responseStream.Write(b2, 0, b2.Length);
        }

        //...
    }

My web.config for said HttpModule:

<add name="JSONAsmx" type="JsonHttpModule, App_Code"/>

And lastly my jQuery call:

<script src="js/jquery.jmsajax.min.js" type="text/javascript"></script>
<script src="js/jquery-1.8.1.min.js" type="text/javascript"></script>

<script type="text/javascript">

    $.jmsajaxurl = function(options) {
        var url = options.url;
        url += "/" + options.method;
        if (options.data) {
            var data = ""; for (var i in options.data) {
                if (data != "")
                    data += "&"; data += i + "=" +
             msJSON.stringify(options.data[i]);
            }
            url += "?" + data; data = null; options.data = "{}";
        }
        return url;
    };

    $(function() {
        var url = $.jmsajaxurl({
            url: "http://www.mywebsite.org/apps/IncidentReportingService/DataService.asmx",
            method: "GetIncidentsByAddress",
            data: {}
        });

        $.ajax({
            cache: false,
            dataType: "jsonp",
            success: function(data) { successCallback(data); },
            error:function(xhr, status, errorThrown) { debugger;},
            url: url + "&format=json"
        });

    });

    function successCallback(data) {
        debugger;
        $.each(data, function(i, item) {
            $("#tweets ul").append("<li>" + item.text + "</li>");
        });
    };

Any ideas?

  • 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-12T04:14:27+00:00Added an answer on June 12, 2026 at 4:14 am

    Well it appeared that my HttpModule was not being implemented all the way. There are methods that I had not overwritten in it and it was causing the entire Web Service not to work.

    I changed it to the following and now everything works:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.IO;
    using System.Text;
    
    public class JsonHttpModule : IHttpModule
    {
        private const string JSON_CONTENT_TYPE = "application/json; charset=utf-8";
    
        public void Dispose()
        {
        }
    
        public void Init(HttpApplication app)
        {
            app.BeginRequest += OnBeginRequest;
            app.ReleaseRequestState += OnReleaseRequestState;
        }
    
        bool _Apply(HttpRequest request)
        {
            if (!request.Url.AbsolutePath.Contains(".asmx")) return false;
            if ("json" != request.QueryString.Get("format")) return false;
            return true;
        }
    
        public void OnBeginRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
    
            if (!_Apply(app.Context.Request)) return;
    
            // correct content type of request
            if (string.IsNullOrEmpty(app.Context.Request.ContentType))
            {
                app.Context.Request.ContentType = JSON_CONTENT_TYPE;
            }
        }
    
        public void OnReleaseRequestState(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
    
            if (!_Apply(app.Context.Request)) return;
    
            // apply response filter to conform to JSONP
            app.Context.Response.Filter =
                new JsonResponseFilter(app.Context.Response.Filter, app.Context);
        }
    }
    
    public class JsonResponseFilter : Stream
    {
        private readonly Stream _responseStream;
        private HttpContext _context;
        private long _position;
    
        public JsonResponseFilter(Stream responseStream, HttpContext context)
        {
            _responseStream = responseStream;
            _context = context;
        }
    
        public override bool CanRead { get { return true; } }
    
        public override bool CanSeek { get { return true; } }
    
        public override bool CanWrite { get { return true; } }
    
        public override long Length { get { return 0; } }
    
        public override long Position { get { return _position; } set { _position = value; } }
    
        public override void Write(byte[] buffer, int offset, int count)
        {
            var b1 = Encoding.UTF8.GetBytes(
              _context.Request.Params["callback"] + "(");
            _responseStream.Write(b1, 0, b1.Length);
            _responseStream.Write(buffer, offset, count);
            var b2 = Encoding.UTF8.GetBytes(");");
            _responseStream.Write(b2, 0, b2.Length);
        }
    
        public override void Close()
        {
            _responseStream.Close();
        }
    
        public override void Flush()
        {
            _responseStream.Flush();
        }
    
        public override long Seek(long offset, SeekOrigin origin)
        {
            return _responseStream.Seek(offset, origin);
        }
    
        public override void SetLength(long length)
        {
            _responseStream.SetLength(length);
        }
    
        public override int Read(byte[] buffer, int offset, int count)
        {
            return _responseStream.Read(buffer, offset, count);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.