title: Javascript / JQuery loop through posted ajax data string to assign new values to
body: <p>I have a function which updates a database via ajax.   My issue is then how to update the data displayed on the page to show updated details. The POST data can vary and therefore the datastring would be something like this:</p>
  
  <pre><code>        var dataString = '[name resource we are editing]=1' + 
          '&amp;para1='+ para1 + 
          '&amp;para2=' + para2+
          '&amp;para3=' + para3
  </code></pre>
  
  <p>I want the function below to split or loop through each of the POST variables in the datastring to update the text of an element on the page.  I cannot figure out how.</p>
  
  <pre><code>function editAccount(dataString, details, form){
          status = $(".status");
          $.ajax({  
            type: "POST",  
            url: "&lt;?php echo BASE_PATH; ?&gt;/edit/",  
            data: dataString,  
              success: function(response) { 
                  $.each(response, function(key, value) { 
                  success_code = key;
                  message = value;
                 });
  
                if(success_code == 1){
                  status.text(message).addClass("valid");
                  //show details and hide form
                  $("#" + details).show();
                  $("#" + form).hide();   
                              //HOW to do below?
                  //update details being displayed with datasource data 
                  //loop through dataString to assign eg. $('#para1')text(para1);
  
                } else {
                  status.text(message).addClass("invalid");
                }
              },
              error: function(response){ 
              status.text("There was a problem updating your details into our database.  Please contact us to report this error.").addClass("invalid");
            }  
          });  
  
      }
  </code></pre>