logo
down
shadow

Nested AJAX request in Javascript/jQuery, it's a good practice?


Nested AJAX request in Javascript/jQuery, it's a good practice?

By : user2954985
Date : November 22 2020, 10:33 AM
I wish this helpful for you Nesting isn't necessarily bad, however an issue here is that if the code above is called more than once over any elements with the class editable-pais that existed the last time the code was called you will end up with more than one click handler. This will generate multiple requests to your inner request's URL.
If you don't need data from the first call to complete this call, or the data can be obtained by other means, you may want to consider un-nesting them. jQuery offers the ability to do delegated callbacks if you need to capture events from elements that may not exist yet:
code :
$("selector for parent element").on("click", ".editable-pais", function (event) { ... });


Share : facebook icon twitter icon
Good practice method for loading JavaScript via ajax

Good practice method for loading JavaScript via ajax


By : Kevin
Date : March 29 2020, 07:55 AM
may help you . In a jQuery environment, I'd use getscript(). You're right to wonder about the cache -- getscript includes a cache-busting feature (designed primarily to defeat aggressive IE caching, although of course useful in other scenarios). You can perform the equivalent of a non-cache-busted getscript like this:
code :
$.ajax({
    cache: true,
    dataType: "script",
    url: "your_js_file.js",
    success: yourFunction
});
jQuery $.each combined with AJAX request - bad practice?

jQuery $.each combined with AJAX request - bad practice?


By : user3403583
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Since you are getting the resultant back in an object and you need something specific to happen with each item, you will need some method of traversing the data. I typically use a standard for loop myself, but that is just out of preference.
The only way to avoid multiple loops would be to get all of the data that you need in one pull, which would then require only one loop.
Nested Ajax request, good or bad practice?

Nested Ajax request, good or bad practice?


By : Mahmud Mithu
Date : March 29 2020, 07:55 AM
To fix the issue you can do I have to make a sequence of Ajax post requests to server using jQuery, and each request is depends on the result of previous response, for example , Use success callbacks
code :
$.ajax({
  url: "URL",
  data: "DATA",
  success: function(data) {

    //data contains the returned data
    //Next ajax here

  }
});
Generating HTML via javascript/jquery. Good programming practice?

Generating HTML via javascript/jquery. Good programming practice?


By : Glenn Butler
Date : March 29 2020, 07:55 AM
around this issue Like that is fine in small doses. If you are in a situation where you need to generate a lot of html, there's a much better way to do it.
Basically, build up your html as a string. Then create an in-memory element and set its innerHTML to your string. You can then append the element to somewhere in the DOM, or operate on its child elements (your html) and do whatever needs doing.
Is Nesting Events a Good Practice in Javascript/JQuery?

Is Nesting Events a Good Practice in Javascript/JQuery?


By : Luke Van In
Date : March 29 2020, 07:55 AM
around this issue This would be simplified by adding a selected class when you click on element.
The current problem is that you will be adding new mouseout event handler each time a click occurs. A new one does not remove the old one
Related Posts Related Posts :
  • React | Can´t load Images > Module not found
  • Dynamically creating buttons in DOJO
  • 404 Not Found in AJAX post call
  • How do I find out, using javascript, what software opened and running my application?
  • Javascript to check the status of wireless connection
  • StarDict support for JavaScript and a Firefox OS App
  • Phonegap event Resume
  • call javascript function on ENTER key press?
  • When is the best time to remove no-js classes from the html tag
  • Recommended email sending languages
  • setInterval not working properly with chrome
  • Does IE create new scope for each script tag?
  • Uncaught SyntaxError: Unexpected token < Underscore and parse issues
  • How to pass captured URL to Email Body in HTML
  • How to structure default nested resources?
  • Store all the keys of a JSON object in a variable
  • Need an efficient way to group the Array of object in javascript
  • a sensible approach to highcharts x-axis labels
  • IDE autocompletion for javascript AMD loading style
  • Bootstrap menu disappears after first click setting the ul style to none
  • split ajax json response errors in each field
  • how to add javascript in head in cmsms
  • REGEX: Finding the correct occurrence order of some given special characters in a string
  • How do you preserve a JavaScript date's time zone from browser to server, and back?
  • Return binary result from phantomjs webserver
  • must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
  • Replacing a substring of an element's text with another string
  • How do I filter marks greater than or equal to 90 in this array?
  • Modify the text of my radio input button?
  • Clicking on status bar does not scroll to top of app (Trigger.io)
  • Mocha JS: How to highlight specific assertion failure?
  • $.getJSON jquery parsing to HTML
  • Find items of a certain class (a) that are also in other classes (b,c,d)
  • Setting different images for D3 force-directed layout nodes
  • Integrating Dropzone.js with angular
  • Control sprite animation speed
  • Can only one error / success function be assigned for AngularJS $http promises?
  • Working with math in javascript
  • Django variable isnt recognized by javascript
  • $.when does not work with $.scrollTo plugin
  • How to read local xml file using $.ajax?
  • Manifest is not Valid JSON. What is wrong?
  • AngularJS re-initialise JS after statechange
  • WebRupee is not working
  • How can I make the jQuery MultiSelect widget read-only?
  • How to associate javascript code with dom elements?
  • How to remove track from MediaStream and "stop" webcam?
  • clearvalidators not working in angular 6 form control
  • Remove Count Attribute in json data
  • queue up function callbacks
  • How to stop all Soundcloud streams in once?
  • Sliding div onclick left/right
  • RequireJS JQuery shim doesnt work with VS2013
  • What is the Meteor concurrency model?
  • Events on children of contenteditable element
  • Simple jquery not working to print the input value
  • Javascript templating language in reverse
  • Making Pagination in Javascript Scalable (for large # of db results)
  • Performance of Stateless Authentication in SPA and SSO (Single Sign On)
  • Assigning a value for view asynchronously
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org