Convert AJAX call from jQuery 1.4 to 1.8

Convert AJAX call from jQuery 1.4 to 1.8

I have the following code that works well if I use jQuery 1.4 however I would like to upgrade to latest version 1.8 and this code returns '0 error' when jQuery above 1.5 is used.

Would someone know what i need to change to make it 1.8 compatible please.

  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head runat="server">
  3.     <title>PA Web Test</title>
  4.     <script src="jquery-1.8.0.js" type="text/javascript"></script>
  5.     <script type="text/javascript">
  6.         
  7.         var offset = 0;
  8.         var howMany = 5;
  9.         
  10.         $(document).ready(function() {
  11.             $("#btnMore").click(function() {
  12.                 // fetch some more records from the server side
  13.                 $.ajax({
  14.                     type: "POST",
  15. dataType: "json",
  16.                     contentType: "application/json; charset=utf-8",
  17.                     url: "http://localhost/PA_Web.asmx/GetData",
  18.                     data: "{'offset':" + offset + ",'howMany':" + howMany + "}",
  19.                     success: onSuccess,
  20.                     error: onError  
  21.                 });
  22.             });
  23.         });

  24.         function onSuccess(result) {
  25.             // process web service return data
  26.             // populate ul with data
  27.             $("#datalist").empty();
  28.             var strings = result.d;
  29.             for (var i = 0; i < strings.length; i++)
  30.                 $("#datalist").append("<li>" + strings[i] + "</li>");
  31.             // move offset
  32.             offset += howMany;
  33.         }

  34.         function onError(result) {
  35.             // ajax call failed
  36.             alert(result.status + ': ' + result.statusText);
  37.         }
  38.     </script>
  39. </head>
  40. <body>
  41.     <form id="form1" runat="server">
  42.     <div>
  43.         <ul id="datalist"></ul>
  44.         <br />
  45.         <input type="button" id="btnMore" value="more" />
  46.     </div>
  47.     </form>
  48. </body>
  49. </html>