www.webdeveloper.com
Results 1 to 4 of 4

Thread: AJAX request call not working

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    35

    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. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    data is a big long string that's too big to post.
    Are you sure it's not being truncated?

  3. #3
    Join Date
    Apr 2005
    Posts
    35
    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?

  4. #4
    Join Date
    Apr 2005
    Posts
    35
    Quote Originally Posted by WolfShade
    Are you sure it's not being truncated?
    It probably is being truncated. I'm going to split it up into segments to see if that helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles