Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. difficult ajax problem in mvc3

difficult ajax problem in mvc3

Scheduled Pinned Locked Moved ASP.NET
helpjavascripthtmldatabasesysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bfis108137
    wrote on last edited by
    #1

    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>
    
    B 1 Reply Last reply
    0
    • B bfis108137

      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: $('&lt;form>@Html.AntiForgeryToken()&lt;/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>
      
      B Offline
      B Offline
      bfis108137
      wrote on last edited by
      #2

      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.

      N 1 Reply Last reply
      0
      • B bfis108137

        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.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups