title: Problems calling AJAX POST from inside a dialog
body: <p>I have a complex page.
  In this pare there is one button.
  The click of this button fires a Javascript:</p>
  
  <pre><code>&lt;input type="button" onclick="javascript:ShowDifferenze('@item.x', '@item.y')" /&gt;
  </code></pre>
  
  <p>This Javascript is in a file .js.
  This javascript opens a dialog, loads data with a ajax GET call, and adds some links to the dialog.</p>
  
  <pre><code>function ShowDifferenze(cod, link) {
      //Funzionante in popup
      $("#dialog").dialog("option", "title", "Mostra differenze");
      $("#dialog").dialog("option", "width", 1200);
      $("#dialog").dialog("option", "height", 700);
      $("#dialog").dialog("open");
      $("#dialog").html('&lt;h2&gt;Loading...&lt;/h2&gt;&lt;div style="margin-top:1em"&gt;&lt;img src="/Content/images/ajax-loader-bar.gif" width="220" height="19" /&gt;&lt;/div&gt;');
      $("#dialog").load('/Gestione/Fonti/Differenze/' + cod, function () {
          $("#dialog").append('&lt;hr /&gt;');
          $("#dialog").append('&lt;div&gt;&lt;span&gt;&lt;a target="_blank" href="/Gestione/Stazioni/FonteWeb/' + cod + '"&gt;Modifica fonte web&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;');
          $("#dialog").append('&lt;div&gt;&lt;span&gt;&lt;a target="_blank" href="/Gestione/Fonti/AggiornaFonte/' + cod + '"&gt;Aggiorna sorgente&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;');
          $("#dialog").append('&lt;div&gt;&lt;span&gt;&lt;a href="/Gestione/Fonti/Differenze/' + cod + '"&gt;Salva le differenze in un file&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;');
          $("#dialog").append('&lt;div&gt;&lt;span&gt;&lt;a href="' + link + '" target="_blank"&gt;VISUALIZZA PAGINA NEL BROWSER&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;');
  
          $("#dialog").append('&lt;div &lt;a href="#" onclick="Javascript:Prova()"&gt;prova&lt;/a&gt;&lt;/div&gt;');
  
          $("#dialog").append('&lt;script&gt; ' +
                              'function Prova() '+
                              '{ '+
                              '  alert("Prova"); '+
                              '  $("#dialog").hide(); '+
                              '} '+
                              '&lt;/script&gt;');
      });    
  
      return false;
  }
  </code></pre>
  
  <p>The last link calls a javascript.
  In the example posted, the javascript works, the alert appears.
  The dialog doesn't close correctly, but this isn't the REAL problem.</p>
  
  <p>Instead of an alert, i need to call an AJAX POST, and here is the real problem: if I change the javascript like this:</p>
  
  <pre><code>$("#dialog").append('&lt;script&gt; '+
                              'function Prova() '+
                              '{'+
                              '  alert("Prova"); '+
                              '  $.ajax( { '+
                              '            type:"POST", '+
                              '            url : "/Gestione/Fonti/Prova/", ' +   
                              '            data: "id="+cod+"&amp;ApriLink=true", '+
                              '            success: function(data) { alert("Aggiornato!"); }, '+
                              '            error: function (error) { alert("error")); } '+
                              '          });'+
                              '}'+
                              '&lt;/script&gt;');
  </code></pre>
  
  <p>nothing works: I don't see the alerts, and the controller is not called.</p>
  
  <p>Any suggestion?</p>
  
  <p>I corrected the code of the javascript as I think it should be ... but still don't work: 
  with FIXED "data" works, 
  data: "id=abcdefgh&amp;ApriLink=true"
  with VARIABLE "data", nothing works
  data: "id="+<strong>cod</strong>+"&amp;ApriLink=true"</p>