AjaxPro and jQuery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikeh3275
    New Member
    • Mar 2008
    • 15

    #1

    AjaxPro and jQuery

    I'm not sure if this belongs on this forum, but if anyone is still using AjaxPro, I'm trying to get it to work with jQuery. I keep getting errors returned similar to this one: null; r.error = {"Message":"wor d s","Type":"Syst em.NotSupported Exception"};/*. Below is the relevant code. Thanks for your help.

    C# code:
    Code:
    using AjaxPro;
    
    public partial class _Default : System.Web.UI.Page
    {
       protected void Page_Load(object sender, EventArgs e)
       {
    	   //load ajax.net files
    	   string path = "/ajaxpro/_Default,";
    	   path += typeof (_Default).Assembly.FullName.Split(',')[0];
    	   path += ".ashx";
    	   Page.RegisterHiddenField("ajaxProPath", path);
       }
    
       [AjaxPro.AjaxMethod()]
       public int deleteService(int lineNumber)
       {
    	   return lineNumber;
       }
    }
    .JS Code
    Code:
    $(document).ready(function()
    {
    	$("img[@id*=delete]").click(function()
    	{
    		var btnID = $(this).attr('id');
    		btnID = btnID.substring(6, btnID.length);
    
    		if (confirm('Are you sure you want to delete service # ' + btnID + '?'))
    		{
    			$.ajax({
    			   type: "POST",
    			   url: $("#ajaxProPath").attr('value'),
    			   data: {s: btnID},
    			   beforeSend: function(xhr)
    			   {
    				 xhr.setRequestHeader("X-AjaxPro-Method", "deleteService");
    			   },
    			   success: function(s)
    			   {
    					alert(s);
    			   }
    			});
    		}
    	});
    });
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Which line triggers that error?
    It sounds like the error is occuring in your backend code, since that error is showing a managed(.NET) excepetion code

    Comment

    • mikeh3275
      New Member
      • Mar 2008
      • 15

      #3
      Originally posted by Plater
      Which line triggers that error?
      It sounds like the error is occuring in your backend code, since that error is showing a managed(.NET) excepetion code
      I don't get a detailed error message back; it comes up through the alert box as part of the response. If I had to guess though, it may have something to do with how I'm setting up the data in the JS Code.

      JS Code:
      Code:
      $(document).ready(function()
      {
      	$("img[@id*=delete]").click(function()
      	{
      		var btnID = $(this).attr('id');
      		btnID = btnID.substring(6, btnID.length);
      
      		if (confirm('Are you sure you want to delete service # ' + btnID + '?'))
      		{
      			$.ajax({
      			   type: "POST",
      			   url: $("#ajaxProPath").attr('value'),
      			   [B]data: {s: btnID},[/B]
      			   beforeSend: function(xhr)
      			   {
      				 xhr.setRequestHeader("X-AjaxPro-Method", "deleteService");
      			   },
      			   success: function(s)
      			   {
      					alert(s); // here is where error message is shown
      			   }
      			});
      		}
      	});
      });

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        So you can't debug through your server-side code and find any problems?

        Comment

        • mikeh3275
          New Member
          • Mar 2008
          • 15

          #5
          Originally posted by Plater
          So you can't debug through your server-side code and find any problems?
          I'm not using Visual Studio if that's what you're asking.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Originally posted by mikeh3275
            I'm not using Visual Studio if that's what you're asking.
            Then what are you using? That was clearly c# code (for asp.net) in the first code block.

            Comment

            • mikeh3275
              New Member
              • Mar 2008
              • 15

              #7
              Originally posted by Plater
              Then what are you using? That was clearly c# code (for asp.net) in the first code block.
              I'm just coding by hand in Dreamweaver.

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Well Visual Web Developer has a free edition. You could try using that.

                I really think it is a problem in the .NET code and not your javascript.

                Comment

                • Bobz

                  #9
                  I know this is an old post, but I thought I would shed some light on this issue in case anyone comes across this post. The error "Word s" NotSupportedExc eption is referring to the property name "s" in the data that is being sent in JQuery's AJAX Method. This property must match the parameter name in the AjaxMethod on the server side. Therefore the correct data parameter to pass in the JQuery AJAX Method is
                  data: {lineNumber: btnID}

                  Comment

                  Working...