difficult ajax problem in mvc3
-
I am very new to ajax (as in this is my first time trying something in ajax) but here is what I am dealing with. I am working on a db4o web server control client. Once finished, I will hopefully be using this in many other projects. What I have at this point is a connect and disconnect button to open and close the db. My code works flawlessly in Firefox but in IE and Chrome it doesn't. I have traced it to a problem where sometimes my Json value (which is just a bool) comes back as null. I stress sometimes in that for no particular reason it just happens. Sometimes it works. Sometimes it doesn't. But it always works in Firefox. However, I have debugged my server side code and the value is never coming back null. In chrome I see that the request comes back as cancelled. The http response and request regardless of successful or fail are identical other than I noticed that the request content-length varies slightly but it doesn't seem to change . This code is supposed to help me with attacks where someone could mimic my ajax request so it sends a validation token as it's body. If there's a better way then please do tell me. Here is my code. My Jquery functions
$(document).ready(function () { $.ajaxSetup({ cache: false, timeout: 5000 }); $("#connectButton").click(function (connect) { connect.preventDefault(); $.ajax({ type: 'post', contentType: "application/json; charset=utf-8", dataType: 'Json', cache: false, url: 'DBAdmin/ConnectDbAjax', data: $('<form>@Html.AntiForgeryToken()</form>').serialize(), success: function (response) { if (response) { $("#disconnectButton").attr("disabled", false); $("#connectButton").attr("disabled", true); } } }); }); $("#disconnectButton").click(function (disconnect) { disconnect.preventDefault(); $.ajax({ type: 'post', contentType: "application/json; charset=utf-8", dataType: 'Json', cache: false, url: 'DBAdmin/DisconnectD</x-turndown>
-
I am very new to ajax (as in this is my first time trying something in ajax) but here is what I am dealing with. I am working on a db4o web server control client. Once finished, I will hopefully be using this in many other projects. What I have at this point is a connect and disconnect button to open and close the db. My code works flawlessly in Firefox but in IE and Chrome it doesn't. I have traced it to a problem where sometimes my Json value (which is just a bool) comes back as null. I stress sometimes in that for no particular reason it just happens. Sometimes it works. Sometimes it doesn't. But it always works in Firefox. However, I have debugged my server side code and the value is never coming back null. In chrome I see that the request comes back as cancelled. The http response and request regardless of successful or fail are identical other than I noticed that the request content-length varies slightly but it doesn't seem to change . This code is supposed to help me with attacks where someone could mimic my ajax request so it sends a validation token as it's body. If there's a better way then please do tell me. Here is my code. My Jquery functions
$(document).ready(function () { $.ajaxSetup({ cache: false, timeout: 5000 }); $("#connectButton").click(function (connect) { connect.preventDefault(); $.ajax({ type: 'post', contentType: "application/json; charset=utf-8", dataType: 'Json', cache: false, url: 'DBAdmin/ConnectDbAjax', data: $('<form>@Html.AntiForgeryToken()</form>').serialize(), success: function (response) { if (response) { $("#disconnectButton").attr("disabled", false); $("#connectButton").attr("disabled", true); } } }); }); $("#disconnectButton").click(function (disconnect) { disconnect.preventDefault(); $.ajax({ type: 'post', contentType: "application/json; charset=utf-8", dataType: 'Json', cache: false, url: 'DBAdmin/DisconnectD</x-turndown>
For anyone who reads this, the problem was AVG Antivirus. I have been killing myself for almost a week now over this searching google and posting to forums etc. And now finally it's the Antivirus. I want to cry. At least it works. hope this post saves someone else the grief that I went through.
-
For anyone who reads this, the problem was AVG Antivirus. I have been killing myself for almost a week now over this searching google and posting to forums etc. And now finally it's the Antivirus. I want to cry. At least it works. hope this post saves someone else the grief that I went through.
Good follow-up.
I know the language. I've read a book. - _Madmatt "The OP herself was not sure about her question" "The OP is from India and I know what she meant." - Shameel