What is wrong with jquery Ajax?

I am using Jquery ajax to receive information from the database. I test server side method.It work properly . when the call in the page was an error json:
Message: “Invalid JSON primitive: }.”

StackTrace:

” at System.Web.Script.Serialization.JavaScriptObjectDe serializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)
depthLimit, JavaScriptSerializer serializer) at System.Web.Script.Serialization.JavaScriptSerializ er.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) at System.Web.Script.Serialization.JavaScriptSerializ er.Deserialize[T](String input) at System.Web.Script.Services.RestHandler.GetRawParam sFromPostRequest(HttpContext context, JavaScriptSerializer serializer) at System.Web.Script.Services.RestHandler.GetRawParam s(WebServiceMethodData methodData, HttpContext context) at System.Web.Script.Services.RestHandler.ExecuteWebS erviceCall(HttpContext context, WebServiceMethodData methodData)”

ExceptionType:”System.ArgumentException”

method sode is :

[WebMethod]
   public static  ParentDataT_book.OptionBook[] SearchNameBook(string nameBook, int state)
   {
       var bookBusiness = new T_bookBusiness();
       return bookBusiness.GetList(nameBook, (byte)0).ToArray();
    }

jquery ajax code is :

function searchBook() {
          j.ajax({
              type: "POST",
              url: "Default.aspx/SearchNameBook",     //نام صفحه و متد
              data: "{'nameBook': '" + j('#ContentPlaceHolder1_txt_nameBook').val() + "', 'state': '" + j('#states').val() - 1 + "'}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (msg) {
                  var delay = function () {
                      AjaxSucceededSearch(msg);
                  };
                  setTimeout(delay, 1500); //remove this
              },
              error: AjaxFailedSearch
          });
          //});
      };
      // });
      function AjaxSucceededSearch(data) {
          if (result.d != null) {
              alert("data is  found!!!");
          }
          else
              if (result.d == null) {
                  alert("data is  not found!!!");
              }
      }
      function AjaxFailedSearch(result) {
          alert(result.status + ' ' + result.statusText);
      }

Friends Do you know what the problem is?


Source: ajax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.