Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

asp.net - jQuery AJAX to ASMX web service works in IE, not in Chrome or FF

I have a ASP.NET webforms project in .NET 3.5 running locally on my machine hosting an ASMX web service. The web service works fine when called from Ajax in IE8, however, using Firefox and Chrome do not work.

The jQuery code is:

$.post("http://localhost:64284/StockService.asmx/DeleteStock",
    { stockId: '"' + code + '"' });

Code is a previous value retrieved from a form element.

This service works fine when invoked from Internet Explorer. It does not work from Chrome or Firefox. I have also tried the $.ajax which doesn't work either.

Firebug shows "OPTIONS DeleteStock" in the Net panel which I find odd as that is the name of the service method. I'd of expected to see POST StockService.asmx however I'm new to jQuery Ajax.

The consuming application is a web forms project, also running on my machine but on another port, but running .NET 4.

Can anyone give any advice? The service is defined as:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class StockService: System.Web.Services.WebService
// ...
    [WebMethod]
    public JimStock[] DeleteStock(string stockId)
    {
        // ...
    }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

check out this post. i implemented the same thing using thispost


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...