Opera, Wii, Ajax, Jquery and asp.net

681 views Asked by At

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 available to get this working on the Wii? Thanks!

3

There are 3 answers

1
offner On BEST ANSWER

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

1
Kip On

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
hallvors On

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)