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/javascript problem

Ajax/javascript problem

Scheduled Pinned Locked Moved ASP.NET
helpjavascripthtmlsysadmintools
6 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.
  • T Offline
    T Offline
    thomasa
    wrote on last edited by
    #1

    I was on a session by Stephen Walther where he introdused client side ajax by a web service, the example was pritty simple:

    <table cellpadding="0" cellspacing="0">
    <thead>
    <tr>
    <td>
    <asp:Button
    id="btnShowDetails"
    runat="server"
    Text="test"
    />
    </td>
    </tr> </thead>
    <tbody id="myTbody">
    </tbody>
    </table>

    </div>
    

    <script type="text/javascript">
    function showText() {
    AjaxWebService.MyWebService.Product.getText(showTextComplete);
    }

        function showTextComplete(result) {
            $("myTbody").html(result);
        }
    

    The web service return a simple string like "<table><tr><td>This is a test</td></tr></table>". The problem is in the function showTextComplete, I always get "Microsoft JScript runtime error: Object expected", it's the $("myTbody") that's wrong. When Walther showed it, it worked fine. So what em I doing wrong? Thanks Thomas

    T 1 Reply Last reply
    0
    • T thomasa

      I was on a session by Stephen Walther where he introdused client side ajax by a web service, the example was pritty simple:

      <table cellpadding="0" cellspacing="0">
      <thead>
      <tr>
      <td>
      <asp:Button
      id="btnShowDetails"
      runat="server"
      Text="test"
      />
      </td>
      </tr> </thead>
      <tbody id="myTbody">
      </tbody>
      </table>

      </div>
      

      <script type="text/javascript">
      function showText() {
      AjaxWebService.MyWebService.Product.getText(showTextComplete);
      }

          function showTextComplete(result) {
              $("myTbody").html(result);
          }
      

      The web service return a simple string like "<table><tr><td>This is a test</td></tr></table>". The problem is in the function showTextComplete, I always get "Microsoft JScript runtime error: Object expected", it's the $("myTbody") that's wrong. When Walther showed it, it worked fine. So what em I doing wrong? Thanks Thomas

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      thomasa wrote:

      function showTextComplete(result) { $("myTbody").html(result); }

      try var myTbody = $get("myTbody"); myTbody.html(result); or myTbody.html = result;

      I didn't get any requirements for the signature

      T 1 Reply Last reply
      0
      • T ToddHileHoffer

        thomasa wrote:

        function showTextComplete(result) { $("myTbody").html(result); }

        try var myTbody = $get("myTbody"); myTbody.html(result); or myTbody.html = result;

        I didn't get any requirements for the signature

        T Offline
        T Offline
        thomasa
        wrote on last edited by
        #3

        var myTbody = $get("myTbody");
        myTbody.html(result);

        gives me the objekt, thus the objekt does't support the method .html(..) (I can acully drop the "var myTbody = $get("myTbody");", since it findes it without it.) I thought maby I could use

        myTbody.innerHTML = result;

        But this gives me a "htmlfile: Unknown runtime error" exeption :(

        T 1 Reply Last reply
        0
        • T thomasa

          var myTbody = $get("myTbody");
          myTbody.html(result);

          gives me the objekt, thus the objekt does't support the method .html(..) (I can acully drop the "var myTbody = $get("myTbody");", since it findes it without it.) I thought maby I could use

          myTbody.innerHTML = result;

          But this gives me a "htmlfile: Unknown runtime error" exeption :(

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          Are you using VS2008? Can you set a break point to see the contents of result?

          I didn't get any requirements for the signature

          T 1 Reply Last reply
          0
          • T ToddHileHoffer

            Are you using VS2008? Can you set a break point to see the contents of result?

            I didn't get any requirements for the signature

            T Offline
            T Offline
            thomasa
            wrote on last edited by
            #5

            Yes, and it is OK with reslut = ""<table><tr><td>This is a test</td></tr></table>"

            T 1 Reply Last reply
            0
            • T thomasa

              Yes, and it is OK with reslut = ""<table><tr><td>This is a test</td></tr></table>"

              T Offline
              T Offline
              ToddHileHoffer
              wrote on last edited by
              #6

              Well then create a string variable and set it to the result. If you have your html object such as a div tag. And a string that is your innerHTML or innerText there is no reason why that shouldn't work.

              I didn't get any requirements for the signature

              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