jQuery Ajax post method not successful (not able to find the path):

jquery ajax post example php
jquery ajax post data
405 method not allowed
$.post is not a function
jquery ajax post json example
jquery ajax example
jquery ajax post json response example
405 method not allowed laravel ajax

I am making an Ajax post method to send some data to my java servlet post method, but issue I am facing is that it is not able to find the path

Here is my HTML code:

<select name="outlet" id="myselect">
  <option>----------------------</option>
  <option>ALL</option>
</select>

And my jQuery (Ajax):

$("#myselect").on("change", function() {
  currentlyClickedOutlet = $(this).val();
  $.ajax({
    url: "./src/com/touchpoint/controller/DateWiseOlWiseSales.java",
    method: "POST",
    data: {
      Outlet: currentlyClickedOutlet,
    },
  });
});

And here is the file tree of my program:

And on browser console it says error POST http://localhost:8080/TPWebReport/src/com/touchpoint/controller/DateWiseOlWiseSales.java 404

If I am giving URL:http://localhost:8080/TPWebReport/DateWiseOlWiseSales then its working fine but the main issue if I ll use this URL then it is for local host only on deployment on server it can cause problem and I don't know why this is happening.

I am using eclipse (2018-09) in eclipse mars 4.1.1 by putting only the java class name it was working fine like URL:DateWiseOlWiseSales it was able to find that class but not here in eclipse 2018-09.

here is my web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>TouchPoint</display-name>
  <welcome-file-list>
    <welcome-file>Login.html</welcome-file>
  </welcome-file-list>
  <servlet>
    <display-name>LoginServlet</display-name>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>com.touchpoint.controller.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/LoginServlet</url-pattern>
  </servlet-mapping>
  <servlet>
    <servlet-name>LogoutServlet</servlet-name>
    <servlet-class>com.touchpoint.controller.LogoutServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LogoutServlet</servlet-name>
    <url-pattern>/LogoutServlet</url-pattern>
  </servlet-mapping>
</web-app>

Put in the Ajax URL field only the servlet name: DateWiseOlWiseSales

$.ajax({
       url : "DateWiseOlWiseSales",
       method : "POST",
....

And add the following to your web.xml

<servlet>
    <servlet-name>DateWiseOlWiseSales</servlet-name>
    <servlet-class>com.touchpoint.controller.DateWiseOlWiseSales</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>DateWiseOlWiseSales</servlet-name>
    <url-pattern>/DateWiseOlWiseSales</url-pattern>
  </servlet-mapping>

POST 405 (Method not allowed) when trying to post AJAX request , Wouldn't this be your issue? Route::get('/ajax/populateApiAuth', 'ApiController@​populateApiAuth');. You set the route up for GET requests, but you're trying to  I'm not sure why it matters whether you leave the file input unfilled, but you need to disable the normal form submission when you use AJAX. The onclick function should return false to do this. <button type=

You should always use a URL, javascript do not know whether your server is Java or PHP or whatever. You could use /TPWebReport/DateWiseOlWiseSales rather than http://localhost:8080/TPWebReport/DateWiseOlWiseSales if your html page is in the same origin.

 $.ajax({
    url : "/TPWebReport/DateWiseOlWiseSales",
    method : "POST",
    data : {
        Outlet : currentlyClickedOutlet,  
    },
});

jQuery calls error callback on successful ajax request (status 200 , can we see some code? just because the status was 200 doesn't the error callback of the .ajax() method to get more information as to what the error is. Here is the Action that receives my Ajax POST request: Firebug does not show any javascript errors. alert("Failure, Unable to recieve content") But If client add one more option in the picklist field then they can't able find that option in the auto complete search box. So, I want to make it as dynamic. So decided to get the values in apex and form a JSON and pass the JSON data from apex to ajax call.

It looks to me like there's a disconnect between what your server endpoints are vs the local development environment. You may be successful on the local host because you have access to that directory. However, when you are in deployment, those sub directories may not be served up. So the net effect is that the . becomes the deployment server endpoint and the server side code only gives up stuff that is exposed. I'm only looking at the snippet but if that's in a client page, then your java server would have to serve up the whole /src/com/touchpoint/controller/DateWiseOlWiseSales.java

Look at your server http handlers in the java server side code and see if that guides you to the problem. Often your server will have to specificiall map the resource to the request.

Learning Web App Development: Build Quickly with Proven JavaScript , UsingjQuery for put and delete Requests In addition to making get and post requests, jQuery has the ability to perform put and delete requests via the general $.ajax function. is the new description"}, }).done(function (response) { // success​! }) a page and received the infamous 404 error, which means the page is not found. For example if the StaticFileMiddleware is not able find a static file which matches the incoming HTTP request then it will invoke the next middleware by calling return _next(context); at the end. On the other hand if it was able to find the requested static file then it will return it to the client and never invoke the next or any subsequent

jQuery.post(), jQuery.post( url [, data ] [, success ] [, dataType ] )Returns: jqXHR arguments this function receives, see the jqXHR Object section of the $.ajax() documentation​. most "Ajax" requests are subject to the same origin policy; the request can not​  not able find parent grid row check box and child grid check box Aug 08, 2013 08:41 AM | user1114 | LINK I have got requirement like i need to find the parent grid row checkbox and if parent grid row checkbox is checked then i need to set all child grid checkboxes to true for that parent grid row checkbox. for that purpose I have done like

Ajax, call jQuery POST to node.js expressjs · GitHub, Is it possible to use ajax without express (just simple node.js)? there is some issue to get the value can anybody help me plssss. I have a problem that responding everything to success, no matter if it is a good var path = require('​path'); $.ajax({ type:'POST', url : '/logout', success : function(data) { location.​reload(); }  How DWR works in Java. JavaScript file that must be included in your application for DWR: 1. Auto generated Javascript of your equivalent class. in this case, my java class name is “Message”, so the javascript complete path is “/<App NAME>/dwr/interface/<YOUR CLASS NAME>.js“.

jQuery AJAX Call to PHP Script with JSON Return · GitHub, [HTML is replaced when successful.] url: "response.php", //Relative or absolute path to response.php file <form action="return.php" class="js-ajax-php-json" method="post" Thank you for wasting an hour of my time trying to get a tutorial with a bug to work. Not explaining anything about 'return,php' makes this useless. Join a community of over 2.6m developers to have your questions answered on Not able to Find a control in the itemtemplate of the listbox of UI for ASP.NET AJAX ListBox.

Comments
  • I'm not trying to come across as rude or condesending but if you have trouble with spelling and grammar, then you should try to use a service like Grammarly or PolishMyWriting as both services are free and can improve your writing a great deal.
  • Share your web.xml please
  • i have include the web. xml file in my code...if you can guide me further with some knowledge it will be very helpfull :)
  • i have more than one java class for which i have to make ajax call like thgis..do i have to map all of them in my web.xml?
  • Yes. You can also use the WebServlet annotation (tutorialspoint.com/servlets/servlets-annotations.htm) directly into the Java classes
  • This way he will always have the constraint to deploy the application under the TPWebReport context.
  • you should always knows where your page's url, and you controller's URL, all web pages only recognize this, they don't know you Java file at all. If your page uses URL as http://localhost:8080/TPWebReport/my_page.jsp, you can also make the ajax url as `./DateWiseOlWiseSales"
  • @sirnino let me try this one
  • We don't even know what his page's URL is. I think he should learn some basic concept before coding. @sirnino
  • what url should i type to acces my java class?
  • You have to move the java class to the folders that are public to the web service... You know like your images, css files etc..