Unable to retrieve information from the wiki API

Here is the link to my codepen project: https://codepen.io/mlestina/pen/OZpOQW?editors=1111

I am having trouble retrieving data from the Wiki API.

When I check the Contr-Shift-J readout, I see:

Loading failed for the <script> with source “https://en.wikipedia.org/w/api.php?action=opensearch&search=dsfds&callback=jQuery331010723807837372779_1525209741598&_=1525209741599”.  index.html:1
An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can remove its sandboxing. OZpOQW
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://static.codepen.io/assets/telefon/bold/af889c53-1ee3-4868-8fdc-2b310d587b50-3-b7a87e0fbd213943fae0c0ef5985635dd43fa9c24876b2725127a13ccaf4ab6a.woff. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). (unknown)
downloadable font: download failed (font-family: "Telefon" style:normal weight:normal stretch:normal src index:0): bad URI or cross-site access not allowed source: https://static.codepen.io/assets/telefon/bold/af889c53-1ee3-4868-8fdc-2b310d587b50-3-b7a87e0fbd213943fae0c0ef5985635dd43fa9c24876b2725127a13ccaf4ab6a.woff unknown:1:24452
Loading failed for the <script> with source “https://en.wikipedia.org/w/api.php?action=opensearch&search=Hitler&callback=jQuery33109582690097080016_1525209907566&_=1525209907567”.  index.html:1
This site appears to use a scroll-linked positioning effect. This may not work well with asynchronous panning; see https://developer.mozilla.org/docs/Mozilla/Performance/ScrollLinkedEffects for further details and to join the discussion on related tools and features!  OZpOQW

The HTML code snippet is:

<body>
<form>
  <input type="text" name="a" id="a"><br>

  <button onclick="passToJ()">Search</button>

</form>
</body>

And here is the Javascript function:

function passToJ() {
    var searchTerm = document.getElementById('a').value;
    console.log("inside function, searchTerm is: ", searchTerm, " and x is: ", x);
    var wikiLink = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + searchTerm + "&callback=?";

    $.ajax({
        url: wikiLink,      
        dataType: "jsonp",
        type: "GET",
        success: function(data) {
            console.log(data); 
        },
        error: function() {
        console.log('error occurred');
    }
})};

Answer №1

After searching through various forums, I was able to find the solution.

The fix involved either;

1) adding event.preventDefault(); to the javascript code, or

2) removing the Form and /Form tags from the HTML

- Matt

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

Error message: JSON.parse encountered an unexpected "<" token at the start of the JSON input

Currently, I am looping through an object and sending multiple requests to an API using the items in that object. These requests fetch data which is then stored in a database after parsing it with JSON.parse(). The parsed data is sent to a callback functio ...

Manage YouTube video played within html code

I am working on a page that contains a YouTube video embedded in HTML. I am trying to find a way to stop the video when it is closed using the YouTube API, but so far my attempts have been unsuccessful. I have included SWFObject and jQuery in the code, yet ...

Once this code is executed, Javascript ceases to function

I have developed a code snippet to create a typing effect similar to a command console. While the code is functioning well on its own, any additional code I add after it seems to malfunction. I've spent quite some time troubleshooting this issue witho ...

Encountering an unrecoverable SyntaxError while trying to deploy a website on Netlify

When using commands like npm start, npm run build, and pm2 start server.js, everything runs smoothly without any errors. However, I encounter an issue when trying to deploy my project on Netlify. The Chrome console displays the error: Uncaught SyntaxError: ...

What is the best way to customize the source code within node modules dependencies?

Hello everyone! I'm facing a challenge with my project. I'm trying to make changes to the code of a component from a UI library, such as Semantic-UI or Material-UI. Currently, I am directly editing the code within the node_modules folder. However ...

How can I correctly export my npm package?

I have successfully developed an npm package. class Person { constructor() {} sayHello() {console.log("Hello World!")} } module.exports = Person; Upon installing the package using npm i my-package, it was integrated into my project. ...

Issue with Socket.io connection event failing to trigger

Having recently delved into the world of socket.io, I followed the provided documentation and watched several tutorials on YouTube to set up a basic functionality. My goal was to see "New socket connection" logged in the console when I visit the index page ...

What could be causing the service method in the controller not to be called by Node JS?

In my current Node JS project, the folder structure of my app is as follows: src │ index.js # Main entry point for application └───config # Contains application environment variables and secrets └───controllers # Hou ...

Having trouble obtaining outcomes from Cloud Code in Parse

After struggling with this issue for quite some time, I have reached a point where I feel the need to seek help. I am working on a cloud code function that is supposed to retrieve a list of categories along with their respective products. Each category con ...

What is the most effective way to prevent JavaScript from running during page load or when the document is ready

I am facing a challenge with my asp.net page. Whenever a textbox is left empty, I want to hide the entire page from the code behind. The issue arises because there is javascript and jquery code that runs on document ready, accessing data from certain page ...

Exploring Joomla and Filezilla for customizing contact forms and updating automatic responses

I'm facing an issue with my website. I've highlighted the specific area where the problem lies below. Here it is: " **result = '<p style="color:white;"><?php echo** JText::_('VG_SK_CONTACT_SUCCESS'); ?></p>' ...

Learn how to efficiently update record orders in an SQL table using ajax within your C# ASP.NET MVC project

I'm having an issue with updating the OrderNumber using JQUery sortable and Ajax. The problem is that formData always appears to be empty. To explain further, I am using FormData to gather sorted rows and send them to the API controller. However, whe ...

Convert HTML table data to JSON format and customize cell values

Hey there, I have a HTML table that looks like this: <table id="people" border="1"> <thead> <tr> <th>Name</th> <th>Places</th> <th>Grade</th> </tr> & ...

Having issues with reading files in PHP using AJAX? Explore alternative methods for downloading files seamlessly

I need to store a value in a txt file and allow the user to download it. Currently, the value is successfully written to the txt file, but the readfile function does not execute, preventing the download from starting. The PHP code is on the same page as ...

Dealing with scenarios where the DOM undergoes changes that overwrite certain variables

I am currently using Ruby on Rails, jQuery version 1.8.3, and jQuery UI version 1.9.2 within my project. Within a view file, I have implemented the rendering of a partial template in the following manner: <%= render :partial => 'template_name&a ...

Unable to Locate Gulp Packages

Whenever I try to run the command gulp in my terminal, my gulp modules are not being found. Surprisingly, all other commands like node -v, gulp -v, and npm -v are working perfectly fine with the latest versions installed. I have tried running these command ...

Achieving checked checkboxes based on already selected values in AngularJS

function Test1Controller($scope) { var storeid = window.localStorage.getItem("storeid"); var serverData = ["Samsung Galaxy Note", "Samsung Galaxy S6", "Samsung Galaxy Avant","Samsung Galaxy Young"]; $scope.items= [] ; var selectedvalue="Samsu ...

Having trouble getting jQuery form validation to recognize the $.post element

I need to create a validation system for my form that covers basic checks like minimum username length, while also ensuring that the username and email are not already in use (requiring a database search). After some trial and error, I've identified ...

Ways to ensure ngModel is accessible across components

I've hit a wall and I'm starting to lose my mind. I've tried all the different methods like FormsModules, ReactiveForms, FORMDIRECTIVES, Input, Output, but I just can't seem to figure out how to make ngModel work between components. My ...

NodeJs guide on removing multiple documents from a MongoDB collection using their _id values

Consider the following array of _ids: ["a12s", "33qq", "121a"] In MongoDB, there are methods such as deleteMany, which allows deletion based on specific queries: var myquery = { address: 'abc' }; dbo.collection("customers").deleteMany(myque ...