2

IEでは正常に機能しているjQueryajax呼び出しがありますが、ChromeとFirefoxではエラーが発生し続けます。アプリケーションの他の場所にも同様のajax呼び出しがあり、すべてのブラウザーで正常に機能しますが、何らかの理由でこれは機能しません。

まず、IE以外のブラウザーで機能しなくなるような明らかなことがありますか。次に、同じように重要なことですが、error: function (e) {}ブロックから何か意味のあるものを取得する方法はありますか。

                $.ajax({
                type: "POST",
                url: "http://localhost:52350/FabRouting/Webservice/FinalizeFileStream.asmx/FinalizeFileStreamDoc",
                data: JSON.stringify({ DocID: docID, FileSize: file.size }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d.length == 0) {
                        //error
                        $("[id$=txtResult]").val("error 0");
                    }
                    else {
                        $("[id$=txtResult]").val(data.d[0].Result);
                    }
                },
                error: function (e) {
                    //error
                    $("[id$=txtResult]").val("error");
                }
            });
4

2 に答える 2

3

エラー関数には3つのパラメーターがあります

error: function(jqXHR, textStatus, errorThrown) { //code here }

1つだけ使用している間。errorThrownには、さらに役立つ情報が含まれているはずです。

EDIT2-キーが文字列ではないために壊れているという私の答えをスクラッチします-それは問題ないはずです。しかし、投稿を使用しているのに、なぜデータを文字列化するのですか?json配列を直接渡すことができるはずです。

于 2012-07-25T17:17:30.983 に答える
0

It ended up not being my code or the browsers (well kinda) after all, just my error.

I kept researching and read something where someone was having trouble with a cross-domain ajax call giving errors. I am not trying to do that, however I did have two Visual Studio web servers spun up for some reason. I looked and I was calling the webservice with a hard coded url (http://localhost:52350/FabRouting/Webservice.......)for the time being and I was using the new url (http://localhost:59986/FabRouting/Tes.....) to access the page.

This was working fine in IE for some reason, but when I was trying it in Chrome or Firefox it was not working. I changed where I was accessing the page and I got a good return value from the ajax call.

I would still like to know how to get a more meaningful error and @dtryan has me part way there. If anyone can help me figure that out I will mark theirs as the answer and not this answer.

EDIT: I later found that I was in fact able to get error messages the way I was trying before and the way @dtryan was suggesting as well. The problem was that for some reason since this was throwing an error because it was trying to go cross-domain, but I wasn't able to capture that error.

I have since had out of memory errors, etc and those I am able to capture and see just fine. I think this just was a perfect storm causing the errors not to be visible. If anyone has any way to capture these errors it would be good to know.

于 2012-07-25T18:05:43.950 に答える