Note that there are some explanatory texts on larger screens.

plurals
  1. POMake code inside ajax response persistent
    primarykey
    data
    text
    <p>I have an AJAX call in my code like this:</p> <pre><code> var resultatAJAX = $.ajax({ url: url, dataType: 'json', async: false, success: function(data) { } }); resultatAJAX.success(function(data) { if (data == "false") { info_estancia[0]['foto'] = "null"; } }); </code></pre> <p>This call executes a php script that checks if the url parameter of the call exists or not. works fine. What I try to do below is to modify a value existent outside the ajax call depending if the response is true or false. </p> <p>Problem is that the changes I do inside the success funcion dont take effect: after the success funcion I check the value of "info_estancia[0]['foto']" and it keeps unmodified.</p> <p>Is there any way to make the code inside the success funcion to persist or in other way get the response of the ajax call outside the function itsetf ?? Something similar to: </p> <pre><code> var resultatAJAX = $.ajax({ url: url, dataType: 'json', async: false, success: function(data) { } }); </code></pre> <p>where resultatAJAX got the True/False response.</p> <p><strong>EDIT</strong></p> <p>Finally it works, dont ask me how but setting some console.logs I supose that something changed and all was fixed. </p> <p>My question now is: Do I need the resultAJAX.success to make the changes persistent or doing the same inside the success of the ajax call woudl work aswell ?? Is better to set the call async then ?? if not, my coude would keep runnging and maybe the value of the "info_estancia[0]['foto']" would not be the desired. am I ritght ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload