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

What is the best way to elegantly display a block containing background and text using Angular and ngAnimate?

I'm a beginner when it comes to JavaScript and Angular. I am attempting to use ng-show and ng-hide for my background and text elements. However, I am experiencing an issue with my text: It smoothly hides, but when it is shown again, the text appears b ...

Error retrieving data from the ngresource properties resource

In the code snippet below, I have a simple factory that requests a json object containing location information. The requests are successful and the data is present in the object. However, there seems to be a scope problem as I am unable to access the prope ...

Allowing SVGs to be clickable without disrupting the functionality of YouTube videos

I'm experiencing an issue with the overlapping of the svg and YouTube elements. If you hover your mouse over, just to the right of the svg and click, instead of opening the video, it redirects you back to the previous page. Clicking on the area betw ...

Exploring the world of Ajax with jQuery

Could someone help me figure out how to integrate Ajax into my PHP code so that the content can load dynamically? Currently, it looks something like this: First, a user selects a category: <li><a href='?genre=sport'>Sport</a>& ...

Ways to retrieve an input field value without triggering form submission

I'm currently working on a payment form where users input the amount in a text field. I also have another text field on the same form that should automatically display the amount in words based on the user input. However, I'm struggling to figure ...

Step-by-step guide on displaying a tag image in HTML using html2canvas

html2canvas($('#header'), { allowTaint: true, onrendered: function (canvas) { var imgData = canvas.toDataURL("image/png"); console.log(imgData); } }); click here for an example ...

Exploring the concept of nested views in AngularJS's UI Router with multiple views integration

I am facing an issue with configuring multiple views on one page, where one view is nested within another. My code in app.js does not seem to be working properly. Below are the details: This is my index.html file <body ng-app="configuratorApp" > ...

Avoid caching in IE9 with ember.js RESTAdapter

I am facing an issue with my Ember CLI application that uses the RESTAdapter. In IE9, the ajax call is being reused from cache, causing data changes not to be reflected. However, other browsers like Chrome always make a proper call to the server. I have e ...

Discover the benefits of utilizing router.back() cascade in Next/React and how to effectively bypass anchor links

Currently, I am working on developing my own blog website using Next.js and MD transcriptions. The issue I am facing involves anchor links. All the titles <h1> are being converted into anchor links through the use of the next Link component: <Link ...

Leveraging React to efficiently connect with friends on Firebase Realtime Database, enhancing the capability to include multiple connections

Currently, I am working on a project that involves React and Firebase's real-time database to create a friend network feature. The main challenge I'm facing is when a user enters an email into an input field. Upon submission, the system takes a s ...

Illuminating individual table cells as a user drags their mouse across a row

My goal is to create a feature that allows users to highlight cells in a table by dragging the mouse over them, similar to what is discussed in the question and answer provided here. However, I would like to limit this drag/highlight effect to only span w ...

Guide on sending emails with AngularJS and the Ionic framework

I have been attempting to send an email by using various links, but without success. I am looking for guidance on how to successfully send an email. Below is the code I have been using for sending emails. Any suggestions for changes would be greatly apprec ...

Tips for sending values via props to a different component and the common error message: "Consider using the defaultValue or value props instead of setting selected on the <option> element"

Currently, I am attempting to pass the selected value using the prop: handle state change, but encountering two errors. Error 1 : Instead of setting selected on <option>, use the defaultValue or value props. Error 2 : A property 'active' ...

What is the best way to switch focus to the next input using jQuery?

Currently, I am implementing the autocomplete feature using jQuery and everything seems to be functioning properly. The only issue I've encountered is with Internet Explorer (IE) - when a user selects an item from the autocomplete list, the focus does ...

Incorporating a new row into JqGrid using Django

When using JqGrid in a Django template, everything works perfectly until I try to add a new row to the grid. I typically use the "+" button on the navigation panel for this purpose. However, whenever I click "Submit" on the "Add Record" dialog, I encounter ...

To change the font color to red when clicked, I must create a button using HTML, CSS, and Javascript

Currently, I am utilizing CodePen to assess my skills in creating a website. Specifically, I am focusing on the HTML component. My goal is to change the font color to blue for the phrase "Today is a beautiful sunny day!" Here is the snippet of code that I ...

Navigating through the Table using AngularJS

I was able to successfully loop through a table using AngularJS to retrieve values from a specified scope named {{rec}} as shown below. HTML <div id="AngularContainer" data-ng-app="myApp" data-ng-controller="myCtrl"> < ...

Checking the image loading functionality with Cypress

I am interested in testing Cypress to verify that an image is successfully loaded onto a page. Here is a snippet of my source code: import React from "react"; export default class Product extends React.Component { render() { return ( <div ...

The browser unexpectedly cancelled the ajax call triggered by the beforeUnload event

Seeking advice on a web application that needs to save user input data through an ajax call when they leave the site. Currently using "Fetch" in a beforeunload event listener, but encountering issues with browsers cancelling the ajax call (specifically th ...

Using the jQuery before() method to manipulate form fields

Is it possible to utilize the jQuery before method to insert a form? An example scenario could be as shown below: <script> $(document).ready(function() { $("button").click(function() { $("button").before('<form><input type="text ...