Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-03-2012, 06:18 PM   PM User | #1
gib65
New Coder

 
Join Date: Nov 2011
Posts: 32
Thanks: 6
Thanked 0 Times in 0 Posts
gib65 is an unknown quantity at this point
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?
gib65 is offline   Reply With Quote
Old 02-03-2012, 07:10 PM   PM User | #2
gib65
New Coder

 
Join Date: Nov 2011
Posts: 32
Thanks: 6
Thanked 0 Times in 0 Posts
gib65 is an unknown quantity at this point
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?
gib65 is offline   Reply With Quote
Old 02-06-2012, 03:19 PM   PM User | #3
gib65
New Coder

 
Join Date: Nov 2011
Posts: 32
Thanks: 6
Thanked 0 Times in 0 Posts
gib65 is an unknown quantity at this point
We now believe the data string is being truncated. We're going to split it up into segments to see if that helps.
gib65 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:50 PM.


Advertisement
Log in to turn off these ads.