Performing an AJAX request from a subfolder

Can anyone help me figure out how to make an ajax request from a page located in a subdirectory and receive a response? On my webpage, index.jsp is situated within a subdirectory called /vf2. In this page, there is a script file included:

<script src="../script/testscript.js"></script>

testscript.js

function getPlaceFromIP3(){

        var ipAdd="1";
         var params ="ipAdd="+ipAdd;     
         var resultStringX = $.ajax({
             type: "GET",
             url:"result_page.jsp",
             data: params,
             async: false
                }).responseText;
         alert(resultStringX);

        }

The result_page.jsp is located in the public_html directory. However, when I call the function from index.jsp, I receive a "page not found" error message. How can I send a request to a page in the main directory from a subdirectory?

Answer №1

If you were to create a standard hyperlink, how would you connect to it? The same concept applies here. Utilize a correct relative URL to the file, starting from the root.

For example, if the file is situated at

http://www.example.com/result_page.jsp
, the URL would be

link:"/result_page.jsp",

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The controller does not support data submission with a POST request, error code

Can someone assist me? I'm currently working on a Java EE website using Spring MVC. I am trying to send a request to the servlet, but I keep getting error 404. Here is my HTML code: <input type="button" value="add" onclick="sendRequest()"> Th ...

Tips for dynamically adjusting an iframe's content size as the browser window is resized

Currently, I am in the process of building a website that will showcase a location on a map (not Google Maps). To achieve this, I have utilized an iframe to contain the map and my goal is for the map to adjust its width based on the width of the browser wi ...

Utilizing React Native to Query, Filter, and Save a Single Document Field Value from Firestore Database into a Variable/Constant

My current task involves setting up a Firebase Firestore Database in order to filter it based on a specific field value within a document. The collection I am working with is named "PRD" and consists of thousands of documents, each sharing the same set of ...

Connect my asp.net grid view to JavaScript using AJAX

I am seeking guidance on how to bind my gridview from JavaScript in an ASP.NET web forms application. My objective is to click a linkbutton within my gridview and have it trigger a modalpopup that displays another gridview. Here are snippets of my code s ...

Using Webpack postcss prefixer with Vue CLI 3

As I work on implementing Bulma CSS in my project using Vue CLI 3, I encounter the need to prefix the classes with webpack. While I found an example of this process, adapting it from a webpack config to vue.config.js poses some challenges. Here is the ini ...

Mongoose Does Not Allow for Duplicate Data Submissions

I'm currently working on a project to develop a basic blog application. Everything works smoothly when submitting content to the database for the first time, but if you try to submit again, Node crashes unexpectedly. I've been struggling to pinpo ...

Utilizing VueJs (Quasar) to access vuex store within the router

Recently, I have been diving into learning Vuex and creating an authentication module. Following a tutorial, I reached a point where I needed to use the store in the router. However, after importing my store at the top of the router index.js file, I notice ...

How can I properly bind a list of objects with nested lists when submitting forms?

Trying to bind a complex object that consists of nested lists of objects poses a challenge. While the data binds to the page successfully with pre-populated content, issues arise when posting the form to the handler method. I can post and bind the parent ...

How can I add text to a textbox within a duplicated div using Javascript or Jquery?

I'm looking to add text to a cloned div's text box using jQuery. I have a div with a button and text box, and by cloning it, I want to dynamically insert text into the new div. $(document).ready(function () { $("#click").click(function () { ...

Retrieving data from a MySQL query output

As a newcomer to PHP and MySQL development, I have created an application in Cordova using Visual Studio. The app functions as follows: The user chooses a serial number from a dropdown menu After selecting a serial number, the corresponding data is displ ...

Is it possible to find out which JavaScript file the AJAX function is using to send a request to a Java servlet?

I am facing an issue with two js files, one.js and two.js. Both of these files make ajax requests to the same Java servlet class(AppController.java). Here is the code from one.js: function addOne(){ var formData = $('#form1').serialize(); ...

Changing HTML dynamically does not trigger the ng-click event within ng-bind-html

I have developed a custom directive that can display messages along with rendering HTML content that may contain Angular attributes like buttons, anchor tags with ng-click attribute, and more. index.html: <ir-error-panel status="status"></ir-err ...

Send the 'key' parameter to the React component

Attempting to pass a parameter named "key" to a react component is resulting in it not functioning properly. However, when I use "keyy" instead of "key," it works as intended. It appears that using "key" as a parameter name may be causing issues due to it ...

Controllers within controllers that fail to choose an option in a select tag dropdown will result in the hiding of another input element

My application utilizes nested controllers following John Papa's style guide, with a controller as approach. One of the controllers manages the form for client validation and submission, while the other is responsible for handling location-related fun ...

JavaScript code using the Jquery library to retrieve the following article from 'cached memory'

I am aware of the easier CSS options for my question, but I am determined to learn JS (Jquery), so please bear with me. My plan: Menu-items are connected to articles within my content division. Initially, only the first article (#intro) is displayed. All ...

Error in PromisifyAll: Callback parameter must be a function

Either my understanding of how BlueBird and its promisify function works is incorrect, or I am making a mistake in the following code. I have an "upload-handler" module that exports one function with a callback: The structure of the upload-handler functio ...

Refresh Google Maps without showing gray areas on the screen

Currently, I am utilizing the Google Maps API v3 in javascript and frequently reloading the map using an app.get while also incorporating layers and bookmarks via mongodb. Whenever I reload the map to erase everything, a gray background appears in the div ...

Placement Mismatch of Radio Button in Form.Check Component of React-Bootstrap

Recently, I've been working on implementing a payment method feature where users can choose their preferred payment option using radio buttons. However, there seems to be an issue with the alignment of the button. Below is the code snippet I have so ...

What is the best way to save the raw text or event-stream data from a JavaScript get request when the server is continuously loading?

Currently, I'm attempting to fetch some basic data from an API. Here is the URL for the request: The issue lies in the fact that the server appears to keep refreshing the page constantly. This endless loading occurs both when using a browser and with ...

Preventing Event Propagation in JQuery Across Different Web Browsers

My GUI controls have a complex nested structure, and I need to prevent events from propagating up the DOM tree when they are clicked or changed. This functionality must be consistent across all browsers. Currently, I am using some cumbersome JavaScript co ...