Difficulty incorporating openId selector into Asp.Net MVC 2

I have been attempting to implement OpenID login functionality on a website using the openid selector JavaScript library. I am following the guidelines provided on this particular site. However, as someone who is not typically a web programmer, I am facing issues with getting it to work and I am unsure of the reason behind this. It seems like it could be something minor, but it's escaping my notice.

The main problem I am encountering is that no image containing the OpenID elements appears where it should, specifically within the

<div id="openid_btns"></div>
section. This leads me to believe that the function responsible for populating this div is not being executed.

My suspicion initially fell upon the scripts.

I followed the instructions to add script references to the Site.Master file as per below:

<script type="text/javascript" src="../../Scripts/jquery-1.4.1.min.js"></script>  
<script type="text/javascript" src="../../Scripts/openid-jquery.js"></script>  
<script type="text/javascript">
    $(document).ready(function () {
        alert("document ready"); // <- I added this to verfiy that this is being called
        openid.init('openid_identifier');
    });  
</script>  

It appears to be invoking the function on every page (the alert pops up), which should mean that the openid.init function is also being triggered afterwards.

This function is defined within the `openid-jquery.js` script:

// Script content here...

I inserted an `alert("initializing")` line into the script, but it never appeared to execute.

Should this function actually be running? How can I inspect why it isn't working as expected? Any thoughts?

UPDATE:

In the document ready function, I swapped the order of the functions like so:

<script type="text/javascript">
    $(document).ready(function () {            
        openid.init('openid_identifier');
        alert("document ready"); 
    });  
</script>  

Now, the alert doesn't appear. What does this indicate? Could there be an issue with the other function? How can I troubleshoot this further?

UPDATE 2:

Oddly, if I rename the `openid-jquery.js` file to something different (anything at all, such as `openid-jquery.2.js`), then I'm able to see the alert from the OpenID script.

However, it only seems to trigger the initial alert and not the subsequent lines. When I add another alert later on (after the very next line), the second alert remains unseen. I'm unsure about the reason behind this as well.

UPDATE 3:

After debugging in Chrome, it appears that the issue stemmed from `providers_large` and `providers_small` not being defined. Adding the following lines to the beginning of the script allowed it to execute and display the alerts. Nonetheless, the images are still not appearing... Looks like I need to investigate further.

Answer №1

It appears that an update is needed in step 4 of the instructions to include the English JavaScript provider information, specifically where the provider_large is defined. Here is the updated code snippet:

<script type="text/javascript" src="../../Scripts/jquery-1.4.1.min.js"></script>  
<script type="text/javascript" src="../../Scripts/openid-jquery.js"></script> 
<script type="text/javascript" src="../../Scripts/openid-jquery-en.js"></script>  
<script type="text/javascript">
    $(document).ready(function () {
        alert("document ready"); // <- Added for verification
        openid.init('openid_identifier');
    });  
</script>  

Answer №2

A small adjustment to the response provided by Sam for version 1.3.

Unzipped Files:

C:\Blah\openid-selector-1.3\openid-selector\js\openid-en.js

Script Tag:

<script type="text/javascript" src="../../Scripts/openid-en.js"></script>

Answer №3

Encountered a similar issue, solution involved updating the web.config file to grant permission for all users to access the specified directories. After making this adjustment, everything functioned as expected.

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

Determine the item in a collection of objects that contains a specific key

What is the most efficient method for locating an object by a specific key in JS when given an array of objects? Utilizing jQuery and underscoreJS is acceptable. I am simply seeking the simplest solution with minimal code. Illustration: Suppose we have a ...

Creating a dynamic JSON array with a single key as an array

After converting data from an excel sheet into a json array, here is the structure: [{ 'booktitle': 'Leading', 'bookid': '56353', 'bookauthor': 'Sir Alex Ferguson' }, { 'booktitle&ap ...

Utilizing variable values in HTML and CSS to enhance a website's functionality

My current project involves modifying an HTML web resource for use in Dynamics 365. I need to replace a static URL with a dynamic value obtained via Javascript, specifically: var URL = Xrm.Page.context.getClientUrl(); There are multiple instances within ...

Retrieving visual information from Google Street View entity

Looking for a solution to extract imagery from the Google Street View panorama within a web page? In my program, I navigate specific routes using Google Street View's javascript API controlled by an embedded Java applet on the same page. I am seeking ...

Leverage variables in Ajax to retrieve the data of an HTML element

Seeking assistance in converting multiple lines into a single for loop. var optie1 = ""; if($('#form #optie1_check').is(':checked')) { optie1 = $('#form #optie1_naam').val(); } var optie2 = ""; if($('#form #optie2_ch ...

What is the proper way to implement v-model with Vuex in <select> elements?

I included a <select> element in my design: <select v-model="amount" required> <option value="10">10</option> <option value="20">20</option> <option value="25">25</o ...

Issue with Material-UI Slider not updating the color of the active range

I am currently working on a Range Slider component that ranges from zero to ten. The issue I am facing is that the values inside the range are not getting colored as expected. Here is My Custom Slider Component: export function VoteRange({ voteRange, set ...

I am attempting to send an array as parameters in an httpservice request, but the parameters are being evaluated as an empty array

Trying to upload multiple images involves converting the image into a base64 encoded string and storing its metadata with an array. The reference to the image path is stored in the database, so the functionality is written in the backend for insertion. Ho ...

Grabbing an AJAX Request

Currently, I am working on a Firefox extension that is designed to analyze the HTML content of web pages after they have been loaded in the browser. While I have successfully captured events like form submissions and link clicks, I am facing an issue wit ...

The Ajax Get Request functions properly when called in a browser, but returns a 302 error when executed within an iframe. What might be causing this discrepancy?

I am currently developing a web application that initiates multiple ajax requests upon startup. The app functions perfectly when executed independently in the browser. However, when I run it within an iframe, one of the ajax requests unexpectedly returns ...

Exploring date comparison in AngularJS

I've encountered an issue while using ng-show in a page that I'm currently designing: <td ng-show="week.EndDate > controller.currentDate"> The week object has a property called EndDate, and the value of currentDate is being set in my c ...

Exploring the process of assigning custom images to individual items within arrays in React JS

Within my Json file, I have an array that details the materials of various foods. When displaying these on my recipe page, each item of material should have a corresponding image. However, with numerous food items and materials, implementing this purely le ...

Tips for resolving the error message: React is not able to identify the `currentSlide` and `slideCount` prop on a DOM element

I recently implemented an image slider using "react-slick" in my next.js project. However, I encountered some warnings in the console related to the 'currentSlide' and 'slideCount' props on a DOM element. Warning: React does not recogni ...

Organize data in a table using a dropdown selection menu

My data structure looks like this: $scope.friends = [ { name:'John', phone:'555-1212', age:10 }, { name:'Mary', phone:'555-9876', age:19 }, { name:'Mike', phone:'555-4321', age:21 }, { na ...

Updating Object Properties in Vue.js 2.0 using Methods

I am facing an issue where I have an object with blank properties in my component's data. I want to update these properties using a method that is triggered by a click event on one of the listed elements. However, when I check the click event in the c ...

Error: The Vue Class-Based module failed to parse due to an unexpected character '@'

When I run the command nmp run serve on my Vue project, I encounter two errors. I am following a tutorial that uses class-based Vue, but I am facing this error with all my imported Vue files. As a newcomer to Vue, I am puzzled as to why this error is occur ...

Prevent IonContent from scrolling to the bottom or top when using Ionic framework

In my Ionic app, I have a long text page with 2 buttons that trigger the actions scrollToBottom and scrollToTop. Due to the length of the page, I have set the scroll duration to be 30 seconds. I am facing two issues here: How can I stop the scrolling ...

Utilizing JavaScript and PHP to dynamically load HTML content on a webpage

Below is the code snippet I'm working with: <?php if ($x == 1){ ?> <b>Some html...</b> <?php } else if ($x==2){ ?> <b> Other html...</b> <?php } ?> Now, I want to create two links (a ...

In order to properly execute the JavaScript code, it is essential to create a highly customized HTML layout from the ER

I am currently utilizing this resource to create a gallery of images on my Rails page. Here is the HTML code required to display the images: <a href="assets/gallery/ave.jpg" title="Ave" data-gallery> <img src="assets/gallery/ave_tb.jpg" alt="Av ...

What could be causing my Angular to malfunction?

I've encountered some challenges while trying to run angular on my computer. I have been studying angular through demos on w3 schools that showcase various components. Currently, I am experimenting with this one: http://www.w3schools.com/angular/try ...