473,569 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dojo xhrPost ajax call not response

12 New Member
If i submit a form, there is no interaction between ajax&servlet.

Expand|Select|Wrap|Line Numbers
  1. function postform() {
  2.                var xhrArgs= {
  3.                         url: "../Ajaxss",
  4.                         form: dojo.byId("myForm"),
  5.                         load: function (message) {
  6.                         dojo.byId("Message").innerHTML = "<div style=\"color:green\">"+message+"</ div>";
  7.                         },
  8.                         error: function (error) {
  9.                                 console.error ('Error: ', error);
  10.                         }
  11.                 };    
  12.                 var deferred = dojo.xhrPost(xhrArgs);
  13.         }  
  14.  
Mar 17 '14 #1
4 2704
chaarmann
785 Recognized Expert Contributor
Maybe your URL is wrong?
You gave "../Ajaxss" as your URL.
Just use an absolute address instead of a relative one for testing. Maybe it goes to the wrong directory.
Also check if your servlet "Ajaxss" is really inside this directory and the server allows clients to access it, especially execute permissions.
Mar 17 '14 #2
mgdvicky
12 New Member
Thank you chaarmann. I'm using this URL also, http://localhost:8080/FinalChapter/Ajaxss. but there is no interaction between ajax.
If i am using action attribute in form tag it'll works fine to interact with servlet, but not with ajax..
servlet code:
Expand|Select|Wrap|Line Numbers
  1. public class Ajaxss extends HttpServlet {
  2.     private static final long serialVersionUID = 1L;
  3.  
  4.     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  5.          PrintWriter out=response.getWriter();
  6.          String    name=request.getParameter("myName");
  7.          out.println("hello" + name + "Welcome!");
  8.     }
  9. }
  10.  
html code:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.             dojoConfig={parseOnLoad: true, isDebug: false}
  3.             </script>
  4.             <script src='../dojoctr/dojo/dojo.js'></script>
  5.             <script src='JsFiles/ajaxpost.js'></script>
  6.             <script>
  7.                 require(["dojo/parser",
  8.                          "dojo/_base/xhr",
  9.                          "dijit/form/TextBox",
  10.                          "dijit/form/Button",
  11.                          "dijit/form/Form"                         
  12.                        ]);
  13.             </script>
  14.     </head>
  15.     <body class="claro">
  16.           <form data-dojo-type="dijit/form/Form" name="myForm" id="myForm" method="post">
  17.           <h3> Example of using xhrpost</h3><br>
  18.           <label for="Name">Enter your Name:</label>
  19.           <input type='text' data-dojo-type="dijit/form/TextBox" name='myName' id="myName"/>
  20.           <button data-dojo-type="dijit/form/Button" type="submit" name="submit" value="submit" onclick="postform()">submit</button>
  21.           </form>
  22.           <div id='Message'></div>
  23.     </body>
  24. </html>
  25.  
[/code]
Mar 17 '14 #3
chaarmann
785 Recognized Expert Contributor
If i am using action attribute in form tag it'll works fine to interact with servlet, but not with ajax.
Then the problem is not Java related. It's Javascript related and for that you should ask for better help in a Javascript or even better Dojo forum.
I have programmed an Ajax test in Dojo where I call a sevlet and it worked, but I have used a different method "request" which is described in dojotoolkit.org documentation "Ajax with dojo/request". So try it out with your sevlet. If it works, then the problem is not server side related, but client side.
As a general advice, you should insert console.log() message at every line of your Dojo program and see in Firebug if the request is really made. (especially one inside function postform). Firebug has a tab where you can see all requests and its status.
If the request was made at all, show inside your Apache (or IIS or whatever server you have) logs if it really arrives and will be processed or will be rejected as an error.
Mar 17 '14 #4
mgdvicky
12 New Member
sure. chaarmann thanks a lot for your valuable response.
Mar 17 '14 #5

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

Similar topics

2
5216
by: Zeba | last post by:
Hi guys! I'm new to JS / Ajax; I've been trying to do an Ajax call to my Webservice ( I'm using C# for code-behind). I'm not using any of the libraries available. I am sending my CustID to the webservice and the webservice returns a Dataset that contains various customer details taken from database. I have tested that the Webservice itself...
3
2058
by: wendallsan | last post by:
Hi All, I've stumped myself writing an app that uses Prototype and a bit of PHP. Here is what I have: I have a custom class named Default_county_init_data that, upon initialization makes several Ajax.Request calls to gather data from the server. What I'm having trouble with is getting the data from the Ajax call back to the custom class...
2
4630
by: gaya3 | last post by:
Hi , can any one please say me how to retreive the array from another jsp thro' ajax call... <%@ include file="JspBean.jsp" %> <html> <head> <link rel="stylesheet" type="text/css" href="../static/js/dojox/grid/_grid/Grid.css">
3
1865
by: rbansalit | last post by:
Hi all I am making a very simple ajax call. But I am not getting any message from sever. <html> <body> <script type="text/javascript"> function ajaxFunction()
9
37282
Claus Mygind
by: Claus Mygind | last post by:
I am having trouble escaping the & in a JSON.stringfy() ajax call. I don't even know if I am stating the problem correctly here. In my app I have linked json2.js from http://www.JSON.org/json2.js 2010-08-25(see attached file) to my app. Then I have created an ajax call in the app to my server_side app in which I invoke the...
5
8804
by: samarinder | last post by:
I am displaying the results by iterating the list in div tag say "results" in my case.For refining of search i am using ajax call. But when i am getting response back from this below snippet document.getElementById("results").innerHTML=xmlHttp.responseText; Its showing me content of JSP in which i am refining my list. I am copying down the...
6
2358
by: agam | last post by:
Here is my ajax call: new Request.HTML({ url: 'users.html', method: 'get', update: 'go', evalScripts: true, /* !! Why isn't this working!? */ onComplete: function(){console.log('ajax complete!')} }).send()
4
1456
Claus Mygind
by: Claus Mygind | last post by:
Is is possible in a php server side app. to both return a success or failure notice to the client app and also send downloaded information to a new client app. Problem: 1) send an ajax request to the server to get data for a Word doc mail merge letter. 2) Have the server a) send the data as if a new page is being streamed out and ...
6
5091
by: rakesh2k78 | last post by:
Hi All, I have a requirement where I need to fire an ajax call(dojo xhrPost)on click of an anchor, but as soon as I click the anchor link browser starts to redirect but ajax call is not finished yet, so I always got bad http return code 0 from the server. I can see in the firebug/developer tool. Is there any way to stop browser redirect until...
0
2793
by: varunkumarid | last post by:
I have tried to download the file from the server through the webmethod but it has not work for me. my code as below public static string GetServerDateTime(string msg) { String result = "Result : " + DateTime.Now.ToString() + " - From Server"; System.IO.FileInfo file = new...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
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...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.