Use ajax to load the script

Encountering a puzzling issue with a script loading function on my IIS local web server.

function loadJs(scriptName) {
    var name = scriptName.toString();
    var myUrl = 'http://192.168.1.149/7.0.9.5/m/js/';
    myUrl += name;
    debugger;
    $.ajax({
        url: myUrl,
        dataType: "script",
        success: function () {  }
    });
}

Despite confirming the correctness of the URL in the debugger, the ajax call does not utilize the expected link:

The intended URL:

We observe that the request URL is different. (The 403 code is due to IIS blocking access to folder listings).

Interestingly, manually entering the URL into the 'url' parameter results in successful loading:

function loadJs(scriptName) {
    var name = scriptName.toString();
    var myUrl = 'http://192.168.1.149/7.0.9.5/m/js/';
    myUrl += name;
    debugger;
    $.ajax({
        url: 'http://192.168.1.149/7.0.9.5/m/js/loadAccount.js',
        dataType: "script",
        success: function () {  }
    });
} 

If anyone can provide insight or a solution to this peculiar problem, it would be greatly appreciated.

Thank you in advance.

Answer №1

Attempt to modify the following line

myNewUrl = myNewUrl + username;

Answer №2

My apologies for the delayed response... Upon investigation, I discovered that the issue lay in having multiple scripts loaded simultaneously. While the first script executed successfully, the second 'scriptname' was actually empty. This explains why the 403 forbidden message error occurred (denying access to the file in IIS).

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

Switch button while moving cursor

I'm struggling with getting this 2048x512 image, which has 4 stages of transition, to work properly. While I know how to switch it to the final stage on hover, I can't seem to figure out how to incorporate a transition effect. Can someone help? ...

Create an instance using the window object in JavaScript

Having an issue when trying to instantiate a class using the window object. I have a namespace called UTIL and within it, there is a class defined as follows: var UTIL = { Classes : {}}; UTIL.Classes.ObservationVal = function(state, id, type, context, pe ...

Display an alert message using alert() if duplicate data is submitted through ajax

I'm using a form and jQuery to submit the form via AJAX. $("form#form").submit(function (event) { //submitting vendor name event.preventDefault(); var formData = new FormData($(this)[0]); //validation for duplicates goes here ...

React- Error: Unhandled Type Mismatch in function call for _this4.getNotes

As I delve into learning React, I've created a basic application to manage notes with titles and descriptions. This application interacts with a REST API built using Go, enabling me to perform operations like retrieving, editing, creating, and deleti ...

Having trouble locating the function in one of the included JavaScript files when receiving an Ajax response?

I have implemented jquery tabs that initiate an ajax call when a tab is clicked. When the tab is clicked, it triggers the ajax call to fetch the HTML response and then appends it to the current page. However, I am encountering an issue; Within the ajax re ...

Configure access control in nginx discourse.conf to allow origin

I'm dealing with an application on forums.awake-gaming.com and have a page on awake-gaming.com that uses AJAX to POST a form to forums.awake-gaming.com. As expected, I encountered the following error: XMLHttpRequest cannot load http://forums.awake-g ...

Ways to showcase a JSON menu with a single level

I have a json file containing links to all the images in a specific folder, as shown below: ["http://img1.png","http://img2.png","http://img3.png","http://img4.png"] I would like to create a <ul> list using this data, but I'm not sure how to d ...

AngularJs JSON endpoint modifier

I've been working on a simple weather app in Angular for practice, but I've hit a roadblock. Here's the Angular JSON feed I'm using: app.factory('forecast', ['$http', function($http) { return $http.get('http: ...

Ways to Insert Text and Values into an Array

{{ "user": "randomuser", "message": "require assistance" }, { "user": "automated assistant", "message": "do you need any help?" }, { "user": "randomuser", "message": "another inquiry" } I am seeking to extract additional paragraphs ...

Sending an empty array using the $.ajax method

My goal is to send the browser's geoposition using jQuery Ajax. if (window.navigator.geolocation) { var failure, success; success = function(position) { var stringData = JSON.stringify(position, null); $.ajax({ typ ...

Issue with unrecognized expression in JQuery when processing Ajax response

Recently, I implemented a JQuery Ajax Form on my website. $('#modal-body-sign-in').on('submit', '#sign-in', function(e) { e.preventDefault(); var data = $(this).serialize(); var url = $(this).attr(&apo ...

Cypress test never finishes when an unforeseen alert is triggered in the system during the test

When a web application unexpectedly throws an error using an alert box, the Cypress test becomes stuck indefinitely. The test will not complete or fail until the user manually closes the browser or clicks on the OK button within the alert box. I have crea ...

In Typescript, we can streamline this code by assigning a default value of `true` to `this.active` if `data.active

I am curious if there is a better way to write the statement mentioned in the title. Could it be improved with this.active = data.active || true? ...

There seems to be an issue with the Google reCAPTCHA login, as it is displaying an error with the code 'invalid-input-secret'

Customer Interface: grecaptcha.ready(function() { grecaptcha.execute('6Le4oroZABBXXIQCQkAYCXYSekNQnWExTeNUBZ-B', {action: 'submit'}).then(function(token) { $scope.userData['repatcha_token'] = token $ht ...

Developing a perpetually scrolling container within a webpage

I am attempting to implement a scrollable div on my webpage that can continuously load content. I am currently using the following code snippet for this --> http://jsfiddle.net/cyrus2013/Qq85d/ $(document).ready(function(){ function loadMoreContent() { ...

Refresh tab controllers in Angular JS on every click event

Is there a way to refresh the tab controller every time a tab is clicked? Here's the current code: $scope.tabs = [ { id: 'tab1', title: 'tab1', icon: 'comments', templateUrl: 'tab1/tab1.tpl.html&ap ...

Extracting information from Python Bottle with the help of AJAX jQuery

I'm currently working on an HTML page that communicates with a Python script returning a JSON string through AJAX/jQuery. I've set up Bottle for basic URL routing functionality. The issue I'm facing is that my browser indicates that the AJA ...

When processing a response from the backend (using express js), cookies are not being received in the browser while on localhost

I'm currently facing some difficulties with implementing authorization cookies within my application. Whenever I attempt to send a GET request to my API (which is hosted on port 8080) from my React frontend (running on port 3000), the cookies that I ...

Vue.js not responding to "mousedown.left" event listener

I am trying to assign different functionalities to right and left click on my custom element. Within the original code, I have set up event listeners for mouse clicks in the element file: container.addEventListener("mousedown", startDrag); conta ...

Error: Attempting to assign a value to the property 'running' of an undefined variable

While working with Nuxt.js, I encountered an issue related to reading the running property of my client object. Here is the HTML code snippet: <b-button v-show="!(projectSelecter(project.ID)).isStarted" //this work just fine variant="success" c ...