"Transforming the CSS attribute from 'none' to 'block' for a

Within my project, I have implemented ajax to retrieve html content for the cenDiv div.

This is how my ajax code looks:

$.ajax({
  dataType: 'html',
  type: "POST",
  url: "oat.php",
  data: {
    standby: standby
  },
  success: function(data) {
    $("#cenDiv").html(data);
    $.parser.parse($('#corWSId').parent());
  }
}); 

Here is a snippet of my oat.php code:

if(isset($_POST['inAppInit']))
{   
 echo '
   ........
   <div style="display:none" id="attFId">...</div>
   <div style="display:block" id="attNId">...</div>
   ........
  ';
}

Now, I am attempting to change the display properties of both elements. This is my javascript function:

function storFirDoc() {
  var docTV = $('#docTitle').val();
  if (docTV == "") {
    alert("not none");
    exit;
  } else {
    alert('test'); //works Ok
    //loadjscssfile('jsui/easyui-1.5.3/jquery.min.js', "js"); 
    //loadjscssfile('jsui/easyui-1.5.3/jquery.easyui.min.js', "js"); 
    $('#attNId').css('display', 'block'); //works fail
    $('#attFId').css('display', 'none'); //works fail
  }
}

I understand that attNId and attFId are not initially present in the DOM since they are returned via ajax. I attempted to reload the necessary js files using the loadjscssfile function, but encountered further issues.

If anyone could provide assistance with my issue, it would be greatly appreciated.

Answer №1

Everything should run smoothly with this solution.

$('#attNId').show();
$('#attFId').hide();

Answer №2

$('#attNId').css("display", "none");
$('#attFId').css("display", "block");

This solution is effective

Answer №3

Using complete: function() in your ajax call is crucial.

Ensure that the storFirDoc() function is only called after the ajax data has been fully loaded, as shown below.

$.ajax({
    dataType: 'html',
    type: "POST",
    url: "oat.php",
    data: {
    standby: standby
    },
    success: function(data) {
        $("#cenDiv").html(data);
        $.parser.parse($('#corWSId').parent());
    },
    complete: function () {
        var docTV = $('#docTitle').val();
        if (docTV == "") {
            alert("Cannot be empty");
            return;
        } else {
            alert('Testing...'); // Successful
            //loadjscssfile('jsui/easyui-1.5.3/jquery.min.js', "js"); 
            //loadjscssfile('jsui/easyui-1.5.3/jquery.easyui.min.js', "js"); 
            $('#attNId').css('display', 'block'); // Issue here
            $('#attFId').css('display', 'none'); // Problem here
        }
    }
});

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

Azure SQL Server linked with a REST API built on Express.js/Node.js encountered an error stating: "TypeError: req.sql is not a function"

Having trouble connecting to Azure SQL Server with express4-tedious. I'm working on building an app in react-native with a Node/Express server (REST API), but encountered this error after setting up express4-tedios in Express: req.sql is not a functio ...

Unable to adjust layout when code is functioning alongside background-color

I'm looking to dynamically change the position of an item on my webpage when it is clicked. Is there a way I can achieve this without relying on id names? I currently have a code snippet that successfully changes the background color, but for some rea ...

Could we incorporate a backwards typewriter animation?

Is there a way to delay this animation for 2 seconds before playing in reverse? I came across this online and made some edits, but I'm still new to this (early stages). Can this be achieved using CSS, HTML, and JavaScript? I plan to use this as an ale ...

Utilizing analytics.js independently of the react-ga library

Is there a way to integrate Google Analytics into my React app without using the react-ga package? I specifically want to access the ga function in a separate JavaScript file as well as within a React component. How can I achieve this by importing the anal ...

What causes materialui styles to vanish upon refreshing in nextjs?

After consulting the materialui documentation (https://material-ui.com/guides/server-rendering/), I was able to find a solution, but I am still unsure of the underlying reason. Why does the style work initially during rendering but disappear upon subs ...

How to structure nested objects within a JavaScript object?

I am looking to create a hierarchical object structure similar to the following: record 1 {id, name, desc} record 2 {id, name, desc} record 3 {id, name, desc} record 4 {id, name, desc} This is a nested structure whe ...

Encountering issues with Laravel Ajax post requests

Despite trying various solutions such as csrf tokens and URLs, none seem to be working for me. Here is a breakdown of my setup: HTML file: <meta name="csrf-token" content="{{ csrf_token() }}"> ... <button id="button" class="btn btn-s ...

The setInterval function in JavaScript fails to update the result

I have successfully implemented a countdown function that is working as expected. // Set the date we're counting down to var countDownDate = new Date("<?= $stop_datejs ?>"); // Update the count down every 1 second var x ...

Create movement in a specific direction using Vivus.js

I'm attempting to create a unique animation where a line starts at the top, then turns right to draw itself using Vivus.js. Unfortunately, I'm running into issues with getting the graphic to animate properly and I'm having trouble troublesho ...

Is there a way to mock a keycloak API call for testing purposes during local development?

At my company, we utilize Keycloak for authentication integrated with LDAP to fetch a user object filled with corporate data. However, while working remotely from home, the need to authenticate on our corporate server every time I reload the app has become ...

Beginner's guide to integrating the @jsplumb/browser-ui into your Vuejs/Nuxtjs project

I am working on the integration of @jsplumb/browser-ui community edition into my application. After receiving a recommendation from the team at jsplumb, I decided to utilize @jsplumb/browser-ui. However, I am facing difficulty in understanding how to begin ...

Adapting a Bootstrap 3 carousel to Bootstrap 5 causes CSS to malfunction

I found a Bootstrap 3 testimonial slider on Codepen that I am trying to recreate. You can view the original here https://codepen.io/frontendor/pen/abBpXWj After adapting the code to work with Bootstrap 5, the carousel functions correctly but the CSS is no ...

There are two different ways to set a hyperlink in HTML. One method is by using the href attribute, where you provide the URL inside the quotation marks. The other

While browsing, I stumbled upon this interesting piece of JavaScript code: onClick="self.location.href='http://stackoverflow.com/'" I incorporated this code into my website, and it seems to have the same effect as using the href attribute. Sin ...

Changing the Color of Links in Bootstrap CSS

I'm completely new to coding and I've decided to dive into the world of Bootstrap. However, I'm facing a hurdle: I can't figure out how to customize the default Bootstrap styles with my own CSS. After researching online, here are the c ...

Having trouble with your CSS on your mobile website?

After developing a website and implementing media queries for responsiveness, everything seemed to be in perfect working order. The website displayed flawlessly on emulators like () and Chrome's inspect element, mirroring my desired mobile design. How ...

Experiencing a disappearing session on Express.js happens approximately every 3 minutes (I can relate to this problem as

I am encountering a similar issue to the question mentioned here: Express.js session lost after about 3 minutes Unfortunately, I have not been able to find a solution yet. This is my Session Code: app.use( session({ secret: 'secret', resave ...

Successfully passing props to the image source using React/Next.js

Currently, in my implementation with React and Next.js, I am utilizing next-images for importing images. I am looking for a solution to pass data directly to the img src attribute, like so: <img src={require(`../src/image/${data}`)} /> It appears t ...

Tips for adjusting the appearance of a datagridview row when hovering over it:

How can I make the color change in a datagridview row when the user hovers over it? Currently, I am only able to get the gray rows to turn blue on hover, but I want this effect to apply to all rows except the footer as well. How can I achieve this without ...

Exploring a new method for AJAX loading when handling large amounts of data into multiple div elements

As I continue my learning journey with html and jquery, I have been exploring ways to replicate monitoring systems (SCADA) into web-based systems. During this process, I discovered openseadragon as a MAP system similar to google maps that allows for overla ...

Is it possible for me to add a div that consistently hovers above other divs on the page

Beginner in the world of CSS. Currently, I am developing a Safari extension where clicking its toolbar button will display a 'dialog banner' (comprising text and a few buttons) on the web page. This banner, in the form of a div, is dynamically a ...