开发者

Opera, Wii, Ajax, Jquery and asp.net

I've written an ajax-enabled web page intended for use on my Wii. However, ajax doesn't appear to work on the Wii's Opera browser. This page works in IE, Chrome and FF, but not in Safari or Opera. Here is my jQuery test ajax call:

$.ajax({
    type: "POST",
    url: "DefaultWebService.asmx/Hello",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) { alert(msg.d); },
    error: function() { alert("error in DefaultWebService.asmx/Hello"); }
});

Here is my test web service method:

[WebMethod]
public string Hello()
{
    return "hello there";
}

There are no calls to DefaultWebService.asmx in my web server logs, so the browser isn't even trying to make the ajax request.

Are there any work-arounds avail开发者_开发知识库able to get this working on the Wii? Thanks!


after a month I hope you've found the solution, but if you haven't I'd like to help out. I wrote a pretty basic test, just this:

<?php
    if( $_SERVER['REQUEST_METHOD']=='POST' ){
        echo file_get_contents('php://input');
        exit;
    }
?>
    <script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script>
    <script type="text/javascript">
    $.ajax({
    type: "POST",
    url: location.href,
    data: '{"test":"passed" }',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) { alert(msg.test); },
    error: function() { alert("error while testing"); }
});
    </script>

but it does work just fine in the Opera versions I tried it in (including some early 9.x versions that might be aligned to the Wii one - I'm not sure what the closest desktop equivalent is though)


Have you tried changing the data being posted? This looks similar (though obviously not identical) to the issue posted here: jQuery syntax error on POST in Opera


Not too familiar with ASP.. could it be that you need to JSON encode the return value? Or does "[WebMethod]" take care of that? Try this:

return "\"hello there\"";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜