how to exit from loop after a ajax call

how to exit from loop after a ajax call

Content Index :

how to exit from loop after a ajax call
Tag : javascript , By : LUK
Date : January 11 2021, 05:14 PM

wish helps you The entire .each loop is iterated before you get to process the responses. You need to sequalize the ajax calls if you want to control the loop based on their results.
Jquwry 1.5 ajax request returns a jqXHR object derived from the Promis interface.
       var res = await $.ajax({
            type: "POST",
            url: "@Url.Action("IsAdmissionNumbervalid", "StudentDetailUpdation")",
            data: JSON.stringify({

                   FieldName: $("#ddlField option:selected").val(),
                   StudentID: $(this).find(".txtStudentID").html(),

            contentType: "application/json; charset=utf-8",
            dataType: "json"


      if (res === "Failed")
         return false;    //exit the loop here

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

jquery exit function in ajax call

Tag : javascript , By : Michael T.
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Is there a way to exit a function, depending on the result of an GET request. , I think the solution can be something like this
function hi () {
        url: "/shop/haveItem",
        type: "GET",
        success: function (data) {
            if (data == '1') {
            } else {
function ifData1 () { /* etc */ }
function ifDataNot1 () { /* etc */ }

Run AJAX call on page exit

Tag : php , By : ยตilad
Date : March 29 2020, 07:55 AM

Why don't I get an infinite loop when I call exit from an atexit handler?

Tag : c , By : user183526
Date : March 29 2020, 07:55 AM
seems to work fine "These callbacks must not call exit()" does not mean "If these callbacks call exit(), special interesting things will happen". It just means "don't do it, or you're on your own". It's possible that a different POSIX-compliant system will do something else, like an infinite loop. Since you didn't follow the rules, you can't count on what will happen.
(I would assume that few if any systems would get into an infinite loop, though. It's trivial to avoid that, and I can't imagine it being a useful result.)

While Loop Won't Exit While Using Read System Call

Tag : c , By : Zinovate
Date : March 29 2020, 07:55 AM
will help you You should use getline() instead of read(). Because getline() does a lot of the work for you. Also, if you only wanted to receive 1 line from input, then simply use read() or getline() without the while() loop that you established. The while loop will be most necessary for multiple inputs, which is what I assumed you wanted since you are calling this a shell type program and your prompt string has sh in it.
If you want to use read() in your code, then you should create your own getline() that uses read(). This could be an example of the code for your own my_getline() function code for your loop using read(), and you should add your conditionals to break as you wish.
char *inputc, input[256];
int i;
for (i = 0; (read(STDIN_FILENO, inputc, 1) != EOF); i++)
    input[i] = inputc[0];
$ cat main.c
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(void)
    size_t size = 256;
    char prompt[5] = "sh$ ";
    char *inputc = NULL;
    /* print out prompt */
    write(1, &prompt, 4);
    while(getline(&inputc, &size, stdin) != -1)
        /* check if input is "quit" to terminate the mini shell */
        if (strncmp(inputc, "quit", 4) == 0)
        /* prints the input */
        printf("%s", inputc);
        /* re-print out prompt to continue loop*/
        write(1, &prompt, 4);
    printf("%s\n", inputc);
    return 0;
$ gcc -Wall -Werror -Wextra -pedantic main.c
$ ./a.out 
sh$ This is a test
This is a test
sh$ See how well getline works!
See how well getline works!

sh$ quit


How to exit loop in an async call?

Tag : ios , By : jehammon
Date : March 29 2020, 07:55 AM
Hope that helps async function call should be avoided inside loop. Suppose checkRoom() method makes API call internally. In that case, loop will run for all rooms and API requests for all rooms would be queued regardless of when you get response for each request.
Ideally you should replace loop with recursion. Call checkRoom() inside a function, let's call it mainFunction(), and wait for the response. If your criterion for joining room doesn't meet, then call your mainFunction() recursively which will make next call to checkRoom() function. Something like this:
var rooms: Array<Room> = []
var currentRoomIndex: Int = 0

func mainFunction() {

        checkRoom() { // async func
            let room = rooms[currentRoomIndex]
            if room.player.count == 1 {
                joined = true
            } else {
                currentRoomIndex += 1
Related Posts Related QUESTIONS :
  • Maximo JS automation script: "importPackage" is not defined
  • How to surround selected text inside textarea with <em> on key combination CTRL+i?
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Make web service not accessible by browser?
  • Select DOM elements within template
  • How to customize angular ui-grid row background color?
  • Binding data in two respective $scope in AngularJS, how?
  • react put some props after import class
  • Variable is distributed among same components
  • switch class in jQuery/JavaScript for active/inactive state
  • How To Track Outbound Clicks Using Javascript
  • How to get total seconds elapsed since the beginning of the month?
  • Protractor: Stale element reference at "browser.wait(EC.visibilityOf(confDial), FIFTY_SECONDS);"
  • Access to an array inside an object
  • Reseting an JavaScript Interval with different value?
  • Learning Angular for the first time - version 2 or 4?
  • Rendering RSS feed (XML) in React with jquery, why do object values parsed from the feed seem empty?
  • Node.js xml2js http.request tag matching
  • applying texture to custom plane geometry in Threejs
  • How do I pass an Event as a function parameter in HTML written inside JavaScript variable?
  • Interface of object parameter with default value and default property
  • Does using try / catch rather than `.catch` observable operator with XHR requests reduce performance?
  • In IE11 background colors not working on printing
  • TypeScript interface signature "(): string"
  • Is synchronous XMLHttpRequest supported in Internet Explorer 10 and 11?
  • Axios function not returning any values with js
  • How to use firestore TIMESTAMP to create time-stamp in JavaScript
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com