title: Is it possible to return javascript function via ajax from php?
body: <p>Is it possible to return javascript function via Ajax from php? Normally I would just return a value then decide what to do with it in plain javascript, but now because I am handling Apache Cordova mobile app I want to do things differently.</p>
  
  <pre><code>account = localStorage.getItem("account");
  account = JSON.parse(account);
  
  $.ajax({
   type: "POST",
   url: example.php,
   data: { account = account.rule }
  });
  </code></pre>
  
  <p>.php</p>
  
  <pre><code>$isAdmin = $conn-&gt;prepare("SELECT role FROM users WHERE username = :username");
  $isAdmin-&gt;bindParam(":username", $username);
  $isAdmin-&gt;execute();
  $result = $isAdmin-&gt;fetch(PDO::FETCH_ASSOC);
  if($result){
   $result = "&lt;script&gt;
   $("header nav").append(
    $("&lt;a /&gt;").attr("href", "admin.html").text("Admin panel")
   )
  &lt;/script&gt;";
  }
  return $result;
  </code></pre>
  
  <p>And then run it. Ill do another check when user redirects to the site.</p>