Odd behavior with $.ajax() in jquery 1.4.2
I've got a page where the user can enter simple data:
- <strong>Description:</strong><br/>
- <textarea id="Desc" rows="5" cols="50"></textarea><br/>
- <strong>Quantity: </strong><br/>
- <input id="QTY" value="0" size="5" maxlength="8" type="text"><br/>
- <strong>Price: </strong><br/>
- <input id="Price" value="0" size="5" maxlength="8" type="text"><br/>
- <input id="AddItem" value="Add To Grouping" type="button">
When they hit the AddItem button I use jQuery and AJAX load the data in to the database (MySQL 5.1.3):
- $('#AddItem').click(function(){
- var QTY = $('#QTY').val();
- var Price = $('#Price').val();
- var Desc = $('#Desc').val();
- var qString = "qty="+QTY+"&price=";
- qString += Price+"&desc="+Desc;
- $.ajax({
- type:"GET",
- data:qString,
- url:"add_item.asp",
- success:function(msg){
- getData(); //Function uses $.ajax() to pull the loaded data for display. Works fine.
- $('#Desc').val('') //wipes the textarea control for the next item entry
- },
- error:function(msg){
- alert('Adding of Item Failed!');
- }
- });
- });
So this works just fine until I enter a description with a '#' character in the textarea. When I do that the description is truncated at the # character when the data is received at the add_item.asp script. What would cause this behavior? I threw some alert()'s in to see what was passed and what came back. Seems it's always the receiving page where the data is truncated at the # character. But it would have to be the submit that's doing this isn't it?
Previous to this I noticed that when I was setting the $.ajax() type as "POST" all the spaces in the description would disappear. However the spaces remain when using "GET" as the type.
Could it be the DOCTYPE isn't declared on the submitting page? The framework of the ASP page has a #include for a global header file. When I tried to add the DOCTYPE declaration to the header it breaks the framework.