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. ajax call to shared (static) mehtod

ajax call to shared (static) mehtod

Scheduled Pinned Locked Moved ASP.NET
helpjavascriptdatabasecsharp
2 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.
  • C Offline
    C Offline
    classy_dog
    wrote on last edited by
    #1

    I am having a problem with an ajax call to a shared (static) vb.net function to obtain data from the database.
    In a vb.net 2010 web form application, I needed to make a call from a javascript function to a shared (static) function to
    obtain data from a sql server 2012 database. The first ajax call below is the original call and the second call is the one
    I came up by copying the first call.
    The problem is the first call always occurs before the second ajax call regardless of what I do with the code. There are cases when I
    only want the second call to occur. By stepping through the code, I see that there is alot of jquery code that occurs.
    $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: document.location.pathname + "/GetStudentLetter",
    data: "{ " + strData + " }",
    dataType: "json",
    success: function (data) {
    LoadEditor(JSON.parse(data.d), milestone);
    },
    error: AjaxFailed
    });
    if (milestone == '999') {
    $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: document.location.pathname + "/Gettattschyr",
    data: "{ " + strData + " }",
    dataType: "json",
    success: function (data) {
    successtest(eval(data));
    },
    error: AjaxFailed
    });
    }
    }
    function successtest(sletter) {
    var sle = sletter
    _txtattschyr = sletter.d
    if (_txtattschyr > '1') {
    alert('You have selected student(s) having more than one Entry for the current school year. ');
    return
    }
    }

    Thus would you tell me what you think is wrong and/or tell me how I can change the second ajax call to try to solve this issue?

    J 1 Reply Last reply
    0
    • C classy_dog

      I am having a problem with an ajax call to a shared (static) vb.net function to obtain data from the database.
      In a vb.net 2010 web form application, I needed to make a call from a javascript function to a shared (static) function to
      obtain data from a sql server 2012 database. The first ajax call below is the original call and the second call is the one
      I came up by copying the first call.
      The problem is the first call always occurs before the second ajax call regardless of what I do with the code. There are cases when I
      only want the second call to occur. By stepping through the code, I see that there is alot of jquery code that occurs.
      $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: document.location.pathname + "/GetStudentLetter",
      data: "{ " + strData + " }",
      dataType: "json",
      success: function (data) {
      LoadEditor(JSON.parse(data.d), milestone);
      },
      error: AjaxFailed
      });
      if (milestone == '999') {
      $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: document.location.pathname + "/Gettattschyr",
      data: "{ " + strData + " }",
      dataType: "json",
      success: function (data) {
      successtest(eval(data));
      },
      error: AjaxFailed
      });
      }
      }
      function successtest(sletter) {
      var sle = sletter
      _txtattschyr = sletter.d
      if (_txtattschyr > '1') {
      alert('You have selected student(s) having more than one Entry for the current school year. ');
      return
      }
      }

      Thus would you tell me what you think is wrong and/or tell me how I can change the second ajax call to try to solve this issue?

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      You have to put the 2nd call inside the success of the firs call, or else the 2nd if statement will never have a value and run before the LoadEditor runs

      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