Server response is not post to html Ajax page

I'm Using ASP.net to do AJAX but I've some problems.

Here is my calcul.aspx page

  protected void Page_Load(object sender, EventArgs e)
    {
        calculs(); 
    }
    private void calculs()
    {
        //Get the request query 
        string n1 =  Request["n1"].ToString();
        string n2 =  Request["n2"].ToString();
        string operation =  Request["operation"].ToString(); 
        int res=0;
        if(operation.Equals("add"))
        {
            res=int.Parse(n1)+int.Parse(n2);
        }
        string strXmlval = "<calcul>" + res.ToString() + "</calcul>";
        // send response to HTML
        // How can we complete this ?
}

 the index.html page :

1    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2    <html xmlns="http://www.w3.org/1999/xhtml">
3    <head runat="server">
4        <title>Untitled Page</title>
5        <script type ="text/javascript">
6         </script>
7    </head>
8       
9    <body>
10       <form name="form1">
11           <div>
12               Nombre 1 : <input type ="text" name="n1" /> <br />
13               Nombre 2 : <input type ="text" name="n2" /> <br />
14               Opération : <select name="operation">
15                               <option value="add"> + </option>
16                               <option value="sub"> - </option>
17                               <option value="mult"> * </option>
18                               <option value="div"> / </option>
19                           </select>
20                           <br /><br />
21                           
22              <input type="button" value="Exécuter" onclick="exécuterOpération()" /> <br /><br />
23              
24              Valeur résultat : <input type ="text" name="valeur" />
25              <br /><br />
26              Résultat (XML) : <textarea name="résultatXML" rows ="7" cols="40"></textarea>
27            </div>
28       </form>
29       <script type ="text/javascript">
30            function exécuterOpération()
31           {
32           debugger;
33               var n1=document.form1.n1.value;
34               var n2=document.form1.n2.value;
35               var opération = document.form1.operation.options[document.form1.operation.selectedIndex].value;
36              
37               if((n1 == "") || (n2 ==""))
38               {
39                   alert("aaa");
40                   return;
41               }
42               
43               var xmlHttp;
44               if(document.all)
45                   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
46               else
47               {
48                   xmlHttp = new XMLHttpRequest();
49                   try
50                   {
51                       netscape.security.PrivilegeManager.enabledPrivilege('UniversalBrowserRead');
52                   }
53                   catch(e)
54                   {
55                   }
56          }
57                
58           xmlHttp.onreadystatechange = function()
59           {
60              if(xmlHttp.readyState == 4)
61               {
62                   var doc = xmlHttp.responseXML;
63                   var calculs = doc.getElementsByTagName("calcul");
64                   var résultat ="";
65                   if(calculs[0])
66                       résultat=calculs[0].firstChild.data;
67                       //résultat = résultat.trim();
68                       document.form1.valeur.value=résultat;
69                       document.form1.résultatXML.value = xmlHttp.responseText;
70               }
71           }
72           var url="http://localhost:49738/Ajax-enabled1/calcul.aspx";
73           url+="?n1=" +n1+"&n2="+n2+"&operation="+opération;
74           xmlHttp.open("GET",url);
75           xmlHttp.send(null);
76       }
77       </script>
78   </body>
79   </html>
80   
81   

 At line 62  xmlHttp.responseXML contains nothing and calculs[0] is empty string.

I think that the response is not post. why ?


f
0
Goraleye
8/25/2008 8:59:47 AM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

1 Replies
467 Views

Similar Articles

[PageSpeed] 19

 below is my suggestion

1. make 'calculs()' as web service

2. attach  java script onclick attribute to the submit button and in that invoke the web service method 'calculs()' and get the response

3. set the responses text to a span's/div's innerHtml  using javascript

Let me know if you need any further assistance on this.

 

 


Thanks,
Atanu, Symphony Services

P.S. Dont forget to mark this as answer, if you have got resolution to your problem from this post.
0
atanu
8/25/2008 1:02:26 PM
Reply:

Similar Artilces:

BUG: Server.Transfer from a non AJAX page to an AJAX page in a different folder
Hi folks,I have some code that was working fine with a previous version of Atlas (v2.0.50727) but when we upgraded it to the release version it causes a HttpUnhandledException to be thrown with a stack trace as follows:at System.Web.UI.Page.HandleError(Exception e)   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)   at System.Web.UI.Page.ProcessRequest()   at System.Web...

I wrote code Response.Redirect then page is not redirected to reqquested page ( ajax.net)
I wrote code Response.Redirect then page is not redirected to reqquested page  (with ajax.net) make sure that your target URL is valied and correct... or the problem might be from your browserRegards...Nassar, RamiMy Blog || E-Mail Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. dear, just paste the code so that we can assist u accordinglyKind Regards,Saurabh Sharmaonly dead fish swim along the flow of river, learn to make yo...

To AJAX, or not to AJAX?
Some body suggested to me to use AJAX. I figured it's not the brand name detergent nor the Dutch city. So here is what I have and please tell me if it ca be done with ajax, and perhaps point me to some examples, etc. The page contains several GridViews and FormViews that display data using several data calls. (Yeah, there is my first issue. Need to figure out how to cash all that.) This is an application that track work orders, so the top most FV has the user info and summary information of the work order. It is editable and so far it works well. There is also another set of infroamt...

ajax or not to ajax.
Heres a strange one for you. I have a textbox, a button and a gridview on a page. I enter some search text which returns 500 odd records in under a second. When i wrap the gridview in an updatepanel, set its update mode to "conditional" and the trigger to the button the page can take 2-4 seconds to render. I think the problem is down to page redering some how as my progress indicator stops at around the same time as the normal postback would appear. I have also noticed this very behaviour and have come to the conclusion that in cases like this it is better to hand code a XMLHttp...

My AJAX is not AJAXing!
Hi, I was having trouble with a new AJAX enabled code so I tried to just to do a simple test page. I did the simple Label control with button example covered in this tutorial http://www.asp.net/learn/ajax/tutorial-01-cs.aspx I'm having the same problem. Functionalitw-wise it works but the page is refreshing and flickering. That means it's not the code but maybe my set up. I'm using VisualStudio 2005 and the application is currenty .NET 2.0. In VS.NET, I do see the AJAX controls though. What could this be?Thanks,Sam did you install the Ajax extensions? Now, it's AJAXing!...

Fetch a page ajax with ajax
In the video number 30 presented by Joe Stagner in “How Do I?” videos, just in the beginning he says that we can fetch an existing aspx page into our page. I doing exactly the same right now, but I’m inserting a page with some controls that triggers events against the update panel that contains a repeater control, such as paging events, filtering and ordering data. I’ve tested the repeater’s control page and it’s working perfectly, though when I insert into another page and trigger an event I got an error, which is undefined. I still can see the page rendered in the first time, the problem o...

Page with AJAX controls posts back twice to the server
I have a form containing three AJAX UpdatePanels, two of which contain a pair of listboxes and a pair of buttons, with the third one containing a pair of radio buttons in a radiobutton list and either three CascadingDropDown lists or two CascadingDropDown lists and a textbox depending on which radio button is selected.  The only other control on my form is a button to submit the information on the form to the server. One thing I've noticed is the information gets posted back to the server twice when the button is clicked.  This causes a duplicate record to be written to two ta...

AJAX Master Page, AJAX Web Form and AJAX Client Control Question?
I gues to get the ball rolling I have VS 2008 and I am creating ASP.NET websites. I have programmed with VS 2005 and always had to add AJAX features by hand. Now in VS 2008 you have new templates AJAX Master Page, AJAX Web Form, AJAX Client Behavior, AJAX Client Control, AJAX Client Library, AJAX-embeded WCF Service On these three templates AJAX Master Page, AJAX Web Form and AJAX Client Control. What makes them different from normal templates? Is it just a matter of adding the script manager to the page or is using a AJAX Master Page have a huge benefit over doing individual pages? I have...

After ajax update panel post back page html reformats oddly
Hi recently started noticing that when i do a update panel post back the html code gets reformated sometime it adds codes which should be there in the first place examples are below. these ones just formating change From                                                            <iframe id="XFram...

html page to colorful AJAX page conversion
  Guys plz  help  Simple code , i  don't know AJAX much  plz help   //* current  html code converting  into  pop up colorful AJAX page but   Script at call button must be working in AJAX page ,    <html><head><title>Call</title><style type="text/css"><!--#ybsw-normal-txheight {        line-height: 14px;}.ybsw-table {        margin: 0px;        padding: 0px;}.ybsw-table table {        bo...

After ajax update panel post back page html reformats oddly #2
Hi recently started noticing that when i do a update panel post back the html code gets reformated sometime it adds codes which should be there in the first place examples are below. these ones just formating changeFrom <iframe id="XFrame1" style="display: block; width: 370px; height: 70px" name="XFrame1" marginwidth="0" marginheight="0" src="" frameborder="1" noresize scrolling="yes"></iframe> To ...

Is Ajax features invalid if set an "ajax page" as an "iframe page" of another main page????
  HI Guys: I upgraded my atlas web application to the ajax v1.0 version and found  a series problem: the ajax feature ( "no postback" ) is invalid in an "iframed page"!!  For exsample: I develop an ajax page A------- yes, it has scriptManager , updatepanel, some buttons in it and so on……,  if I open the page in a unique IE brower, everyting works fine , i can savor the amoratic breeze of ajax effects; however , If I open page B where these codes place:  <iframe src=http://page A url   width="700px" height="700px" scrolling="...

Ajax(AJAX EXTENSION) and page parsing
anyone can help me i have a problem.i use ajax extension When I save my page's data I get an error stating "Sys.WebForms.PageRequestManagerParserErrorException : The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, httpModules, or server trace is enabled. Details: Error parsing near 'itle||Untitle Page|<script language='ja'.Actually after saving  the data i am showing javascript msg from server side.following is the code<form><asp:ScriptMan...

Failing to retrieve data from HTMLIn my HTML page that calls Ajax I have a field defined as:-<td width=195 style="position:absolute; visibility: hidden;" id="CNumber" name="CNumber"></td>and in Ajax I
In my HTML page that calls Ajax I have a field defined as:-<td width=195 style="position:absolute; visibility: hidden;" id="CNumber" name="CNumber"></td>and in Ajax I attempt to retrieve its contents by :-        var KaartNommer      = document.getElementById("CNumber").innerHTML;and I have also tried:-        var KaartNommer      = document.getElementById("CNumber").value;both fail and doing an alert() I get told that it is undefined.Please tell me how I got t...

Web resources about - Server response is not post to html Ajax page - asp.net.ajax-discussion

Wikipedia:Abuse response - Wikipedia, the free encyclopedia
For a list of current Abuse Response volunteers, or for information on how you can help with the Abuse Response project, please see the volunteers ...

George Pell’s Melbourne Response child sexual abuse program
THE victims of child sexual abuse within the Catholic Church just want to be heard.

NSW hospitals: Ambulance response times slow as overtime bill increases
An Auditor-General's report on NSW hospitals shows that ambulance times have slowed.

Climate aid is a poor response to global challenges
Money being earmarked for climate aid would improve the lives of more people if spent on health and education programs.

GOOD NEWS: Obama has no response to Iranian Ballistic Missile Tests
... Tower Senators Kelly Ayotte (R – N.H.) and Mark Kirk (R – Ill.) expressed their concern on Tuesday regarding the White House’s lack of response ...

"Fluent in Nazi": Trump provokes varied responses in Middle East
Some are rejecting the GOP frontrunner's views on Muslims, while others are just making fun of him

Chipotle grilled for crisis response
Crisis PR professionals have some harsh words for Chipotle for its handling of outbreaks of E. coli and norovirus.

Where's the official Republican Party response to Trump's Muslim ban plan?
... "Heil Donald Trump - THE ULTIMATE SAVIOR." That's what Andrew Anglin, publisher of the neo-Nazi website Daily Stormer, had to say in response ...

Rubio: Obama's response to terror has Americans scared - On Air Videos - Fox News
Republican presidential candidate reacts to president's address from the Oval Office

Proposed French Law Would Ban TOR In Response to Terror Attacks
... considereing banning the use of TOR, a service that anonymises users on the internet. It would be one of a range of measures passed in response ...

Resources last updated: 12/11/2015 12:51:14 PM