0

Let me explain. I'm writing code and added breakpoint before some ajax query. I've analysed data from variables and now want to prevent ajax query execution, but if I resume code, it will be executed. I can refresh page and ajax query will not be send, but how to do this without loosing page changes on the fly?

1
  • Do you want to debug JavaScript code before sending the ajax request ??? Commented Apr 22, 2016 at 8:10

1 Answer 1

1

How did you call your AJAX function?

If you call it like this

function AJAXCaller() {
    ... // CODE THAT ANALYZE THE DATA
    $.ajax({ ... });
    ... // CODE CONTINUATION
}

then you could probably add some variable as a flag to decide whether to run the AJAX or not like this

var runAJAX = true;

function AJAXCaller() {
    ... // CODE THAT ANALYZE THE DATA
    if(runAJAX) {
        $.ajax({ ... });
    }
    ... // CODE CONTINUATION
}

then you could add the breakpoint at the if(runAJAX) {, then if you decide not to run the AJAX call, change the runAJAX value using the console

Sign up to request clarification or add additional context in comments.

2 Comments

Change javascript in devtools on the fly? I had not thought about it. Looks like good idea)
@Kein, yes you can try changing the value to continue or skip the AJAX call from the console in the developer options, hope it could help solve your problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.