Failure to include jQuery and CSS in the AJAX response

Having trouble with my slider. The script that is added at runtime is not showing up in the ajax response. Does anyone know why this might be happening?

$.ajax({
    url:"ajax_get_response_eng_to_change.php",
    type:"POST",
    async:true,
    data:{cat_id:"cat_id",obj:obj } ,
    beforeSend: function(){

        }   
    })
    .done(function(resp){ 
          thumbGallerySetupDone();
             var json_obj = jQuery.parseJSON(resp); 


            var output=   
"<div class='a2' style='display: block;height: 185px;color:white' id='outg"+obj+"'>"+
           "<div id='componentWrapper' >"+
             "<div class='thumbContainer'>"+
                "<div class='thumbInnerContainer' id='g"+obj+"'>";
                for (var i in json_obj) 
               {
output+= "<div class='thumbHolder'><a class='pp_content' data-rel='prettyPhoto[gallery1]' href='administrator/public/upload/"+json_obj[i].cat_meta_img+"' title='"+json_obj[i].sub_n+"' ><img  class='thumb_hidden' src='administrator/public/upload/"+json_obj[i].cat_meta_img+"' width='180' height='120'/></a> </div>>";
                    } 

    output+= "</div></div> <div class='thumbBackward thumb_hidden' id='previo'><img src='data/icons/thumb_backward.png' alt='' width='21' height='31' /></div>  <div class='thumbForward thumb_hidden' id='nexta' ><img src='data/icons/thumb_forward.png' alt='' width='21' height='31' /></div></div></div>";


        $("#prev_response").append(output);

        });

Answer №1

Perhaps the issue stems from setting async:true, as it doesn't allow for the ajax call to finish, which may be causing the problem.

You could attempt using async:false (Please note: this has not been tested).

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: 'delay' is not recognized as a valid function

I'm encountering an error message that reads as follows: $("div.valid_box").html(data.message).css("margin-left", "145px").css("width", "520px").show().delay is not a function [Break On This Error] $(...elay(10000).hide("slow", function() { within m ...

Transferring data from jQuery Ajax to PHP

I'm facing a challenge in retrieving a value back to PHP that I can manipulate and save to the database. It appears that using the GET method with jQuery AJAX is not yielding the desired results. Below is the PHP code snippet where I attempt to captur ...

What is the process for performing the "extract function" refactoring in JavaScript?

Are there any tools for extracting functions in JavaScript similar to the "extract function" refactoring feature available for Java and jQuery developers in Eclipse or Aptana? Or perhaps in another JavaScript/jQuery IDE? ...

When subjecting an ASP.NET application to load testing with 100 users using JMeter, an error related to jQuery functionality is

As part of load testing for my asp.net application using jmeter, I am simulating only 100 users. The issue arises when jQuery is present on the page at "Scripts/jquery.min.js" and an error occurs in 20% of cases as shown below: Sample Result :- Thread N ...

Passing a PHP variable between PHP files with the help of jQuery

I'm facing a minor issue. I'm trying to pass a PHP variable from one PHP file to another using setInterval. However, I'm unsure of how to include the PHP variable in my jQuery code. Here is the content of first.php: <?php $phpvariable= ...

Tips for positioning a div to the left once the minimum width has been reached?

<div id="container"> <div id="subsSection"> <div class="leftSection">ss</div> <div class="rightSection">ss</div> </div> </div> (1) My goal is to have the subsection div centered on the ...

Looking for a way to achieve a dynamic image zoom and pan effect similar to Google Maps using jQuery or JavaScript?

The objective is to allow the user to manipulate the image within a static frame and subsequently crop the image using rails. Up until now, my search has led me to , but I am curious if there is a tool that also includes image cropping capabilities? Appr ...

The issue with the `.load` function in jQuery not functioning properly

I'm currently tackling an issue with a project where I am encountering difficulties with the .load function not working in Google Chrome. Below is the JavaScript code: function link1() { $('#loadarea').html('loading.....' ...

Having trouble integrating SVG icons into my Angular project

I'm encountering an issue with adding icons that I've designed in Figma to my web application. Some of the icons are displaying correctly while others are not. Here is the code snippet I am using to add the icons: .dx-icon-info { mask-image: ...

Increase visibility, decrease visibility by utilizing ng-hide/ng-show and functions

As I implement the show more/show less feature, I am uncertain if achieving a smooth effect is feasible. However, I believe it's worth reaching out to this community for some creative ideas on how to make it possible. I have a list of dynamic links w ...

What is the best way to develop a widget that loads asynchronously by implementing AJAX, JavaScript, and PHP?

Currently, this widget is in need of items that are sourced from a php file. For instance, the javascript function should generate a table within this div element. <div id="widget"></> The aim is to dynamically update the content with the ht ...

jQuery modal popup failing to display the value of an element

When attempting to display content in a Bootstrap 4.0 modal on an ASP.NET Core 3.1 Razor page, the jQuery shown.bs.modal event seems to be failing to show the element value within the modal. Strangely, logging the assigned value to the console displays it ...

Challenge encountered in Ajax with data processing

Help needed with making an ajax request to update the "status" parameter of my "task" object. The script is set up to retrieve the task ID and the new status, but I'm encountering errors in either the routes.rb file, the update_status function within ...

What is the best way to connect to a specific part of a webpage that functions properly on Safari?

On my website, I have a testimonials page with a featured testimonial on the homepage that has a "Read More" option. When users click on this link, I want them to be taken directly to the testimonials page and to the specific section where that particular ...

encountered an issue with the code for submitting the form using ajax

<form action="" method="post" class="f-color" id="email-form"> {% csrf_token %} <label>Name</label> <input type="text"> <label>From</label> <input type="e ...

Django doesn't receive the Ajax post data

Currently, I am in the process of developing a Django application where I am utilizing jQuery and Ajax for handling a POST request. However, I am encountering difficulties with sending data from the frontend to the server using Ajax. views.py def add_new_ ...

Alternative to Google's translation API

While utilizing the Google translate API, I have noticed that it disrupts the css on my webpage by removing background images. Does anyone have a different suggestion or solution? I attempted to find a JQuery method that translates text inline without ref ...

The AJAX call in PHP is echoing JavaScript code that seems to be malfunctioning

Currently working on an AJAX page using php, where I plan to output a section of JS code upon completion. Despite having the JS code within the HTML page, it is not functioning properly. Any suggestions on how to get it to work? ...

Close button for colorbox modal window containing an iframe

I'm currently utilizing colorbox for a modal popup, and the content of the popup is being sourced from a URL. Since it's displayed within an iFrame, I'm wondering how I can incorporate a close button to the modal popup. Thank you The follo ...

Dynamically Remove One Form from a Django Formset

I have been using the following code to dynamically add a form to my formset: .html {{ form2.management_form }} <div id="form_set"> {% for form2 in form2.forms %} <table class="table table2" width=100%> ...