473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[ASP.Net] Cannot Send "&" with XMLHttpRequest

ak1dnar
1,584 Recognized Expert Top Contributor
When I am sending a form Input like in this format using ajax to my ASP.Net page;
term=ASP & PHP

Using This JavaScript;
Expand|Select|Wrap|Line Numbers
  1. function myFunc(term_from_form){
  2. var qstring = "term="+term_from_form; // ASP & PHP
  3. url = 'ServerPage.aspx';
  4. setParams(url,qstring)
  5. }
  6. function setParams(url,params){
  7.       makeobj(); // Creating http_request here
  8.       http_request.onreadystatechange = buildOutPut;
  9.       http_request.open('POST', url, true);
  10.       http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  11.       http_request.setRequestHeader("Content-length", params.length);
  12.       http_request.setRequestHeader("Connection", "close");
  13.       http_request.send(params);
  14. }
Only "ASP" part is getting,"& PHP" part is missing.

Expand|Select|Wrap|Line Numbers
  1. Dim SearchTerm As String = Request.Form("term")
the remaining part of the string is missing.(after the "&")
How to fix this? Thanks.
Nov 30 '07 #1
3 1675
Plater
7,872 Recognized Expert Expert
params are sent in the format of:
key1=value1&key 2=value2

So by straight using the the & you make it think that the "PHP" part is a new "key".
Try calling the escape() function onr your string first.
Nov 30 '07 #2
ak1dnar
1,584 Recognized Expert Top Contributor
params are sent in the format of:
key1=value1&key 2=value2

So by straight using the the & you make it think that the "PHP" part is a new "key".
Try calling the escape() function onr your string first.
Expand|Select|Wrap|Line Numbers
  1. function setParams(url,params){
  2.       makeobj();
  3.       alert(params) //term=ABC & DEF&area=London 
  4.       var encodedInputString =escape(params);
  5.       alert(encodedInputString) //term%3DABC%20%26%20DEF%26area%3DLondon
  6.       http_request.onreadystatechange = buildOutPut;
  7.       http_request.open('POST', url, true);
  8.       http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  9.       http_request.setRequestHeader("Content-length", encodedInputString.length);
  10.       http_request.setRequestHeader("Connection", "close");
  11.       http_request.send(encodedInputString);
  12. }
  13.  
I tried that also. but see my sample Input String here. For that String the server side response is like this.
Expand|Select|Wrap|Line Numbers
  1. Dim SearchTerm As String = Request.Form("term") ' Nothing
  2. Dim area As String = Request.Form("area") ' Nothing
  3.  
Is that mean ASP.net is not reading this line ?
//term%3DABC%20%2 6%20DEF%26area% 3DLondon
Dec 1 '07 #3
Plater
7,872 Recognized Expert Expert
Hmm I guess it is escaping TOO much, as it escapes the = signs and stuff too.
Try calling escape() on just parts
so like "key="+escape(v alue)+"&key2="+ escape(value2) (etc..)
Dec 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

23
5688
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've reduced my form request to a simple text string entry, instead of my desired optional parameters. As i have been stuck with a single unfathomable glitch for over a year. Basically, if i enter queries such as ; "select * from table" "select * from...
2
1851
by: DC Gringo | last post by:
I have an image control (that pulls an image off an ESRI map server): <ASP:IMAGE ID="imgZonedCountry" RUNAT="server"></ASP:IMAGE> In the code behind I am setting the ImageURL to a String value with url parameters like this: imgZonedCountry.ImageUrl = "http://server/servlet/com.esri.wms.Esrimap?param1=x&param2=y When it serves up the page, I'm getting "&amp;" in place of the "&"
2
20538
by: Eric Osman | last post by:
Hi, I'm looking for a javascript function that will convert input such as this: <CLUB Code=" into this: &lt;CLUB Code=&quot;
4
14811
by: barney | last post by:
Hello, I' m using .NET System.Xml.XmlDOcument. When I do the following: XmlDocument xml = new XmlDocument(); xml.Load("blah"); .... xml.Save("blub"); I've got the problem that the following expression: .... snip ...
5
3450
by: martin | last post by:
Hi, I would be extremly grateful for some help on producing an xml fragemt. The fragment that I wish to produce should look like this <Addresses> <Address>&qout;Somebody's Name&quot; &lt;me@mydomain.com&gt;</Address> </Addresses>
3
3104
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn =server.createobject("ADODB.connection") objConn.open "DSN=Photo" Dim sqlSELsite,ObjRSSel sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
2
2074
by: Me | last post by:
I am passing on the input name to my asp page using Response.redirect "mypage.asp?name=" & name and the resulting url looks like 'companyname/mypage.asp?name=" & name I would like it to appear like 'companyname' or at most 'companyname/mypage.asp' how can I do it?
13
2806
by: Ragnar | last post by:
Hi, 2 issues left with my tidy-work: 1) Tidy transforms a "&amp;" in the source-xml into a "&" in the tidied version. My XML-Importer cannot handle it 2) in a long <title>-string a wrap is produced like: <title>my very long title blab la blab la Blabla bla </title> Importer also has got problems with it
30
3857
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at the end of the app for example: class test { public: int x;
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.