Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    36
    Thanks
    6
    Thanked 0 Times in 0 Posts

    AJAX request call not working

    Hello,

    I'm trying to track down a bug.

    On the client side, I've got some javascript code that makes an AJAX request to the server. The request seems to be returning to the callback function with readystate 4 but no XML data. I'm working in Visual Studios 2008 and I have confirmed with the debugger that the codebehind C# code that's supposed to be run when the server receives the AJAX request isn't running at all (which explains the lack of XML data in the response). I'm having trouble figuring out why this is.

    The AJAX call looks like this:

    Code:
            http_request.open(method, filename, async);
            http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            http_request.send(data);
    method = 'POST'

    filename = 'ChargeCodeSave.aspx'

    async = true

    data is a big long string that's too big to post.

    Once this request gets sent, it goes off into cyber-space and the debugger can't trace it. All I know is that the codebehind specified in ChargeCodeSave.aspx, which is ChargeCodeSave.aspx.cs as the following (and only) line from ChargeCodeSave.aspx shows:

    <%@ Page language="c#" Codebehind="ChargeCodeSave.aspx.cs" AutoEventWireup="True" Inherits="CoreData.Net2.ChargeCodeSave" %>

    isn't run.

    I don't think you'd need to know what the Page_Load method in the C# codebehind file looks like (since it's not even executing), but here it is anyway:

    Code:
    		protected void Page_Load(object sender, System.EventArgs e)
    		{
                // Clean the cache of CommonSession for each page load.
                TimeSheetUtility.ResetSessionCache();
    
                MessageBox.Show("message box");
    
    			XmlDocument xmlReply = null;
    
    			ParseInput ();
    
    			// Parse the input variables
    			switch (Request.Form["action"])
    			{
    				case "validate" :
    					xmlReply = Validate ();
    					break;
    				case "process" :
    					xmlReply = Process ();
    					break;
    				default :
    					break;
    			}
    			// Set the encoding of the document
    			Response.ContentEncoding = System.Text.Encoding.UTF8;
    			Response.ContentType = "application/xml";
    
    			// Output the response of the loading
    			Response.Write (xmlReply.OuterXml);
    		}
    Can anybody suggest what the problem might be?

  • #2
    New Coder
    Join Date
    Nov 2011
    Posts
    36
    Thanks
    6
    Thanked 0 Times in 0 Posts
    UPDATE: it doesn't seem to like "x-www-form-urlencoded". If I replace that with "x-www-form-utf8encoded", as in the following line:

    http_request.setRequestHeader("Content-Type", "application/x-www-form-utf8encoded");

    the codebehind actuall executes.

    The problem now is that the request form is empty so that Request.Form["action"] doesn't give me anything.

    I'm also not sure that "application/x-www-form-utf8encoded" exists. Is there something else I can use?

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    36
    Thanks
    6
    Thanked 0 Times in 0 Posts
    We now believe the data string is being truncated. We're going to split it up into segments to see if that helps.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •