0

サーバー側で ajax イベントの Word ドキュメントを作成しています。エラーがなければ応答として、ダウンロードをプッシュしたいと思います。jquery ajaxで可能ですか?私のコードは、この瞬間を次のように見ています

                $.ajax({
                       type: "POST",
                       url: 'docsx.php',
                       data: $("#edit_form").serialize(), // serializes the form's elements.
                       success: function(data)
                       {
                        **here should be fired the download** // show response from the php script.
                       },
                       error:function(){

                           alert('Es gibt ein Fehler bei Daten übetragung!');

                        }
                     });
4

3 に答える 3

0
  <div id="Status_Update" title="Update your Status Here">
    <form method="post" action="update_status.php?<?php echo(SID); ?>" name="Status_form" id="Status_form">
      <span id="sprytextfield1">
      <label for="text1"></label>
      <label for="textfield6"></label>
      <textarea class="ns_tb" name="status_update_box" cols="60" placeholder="What is on your mind" style="font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; border: thin solid #0C0; border-radius:9px;"></textarea>
<span class="textfieldRequiredMsg">A value is required.</span></span>
      <input type="submit" name="status_update_button" id="button" value="Post" style=" background-color:#0C0; border-radius:9px;)"/>
      <a href="#" id="hide_status_box" tittle="Hide the Status Comment Box">hide</a>
    </form>
  </div>
于 2012-09-22T20:40:34.900 に答える
0

私はこれを自分で一度行ったことがあります.phpでファイルを生成し、サーバーのどこかに置いてから、スクリプトへのパスを返すことができます。次に、非表示の iframe を作成し、単純なスクリプトを呼び出してファイルを読み取り、ダウンロードを強制する適切なヘッダーを設定して返します。結果は、ページを更新せずに強制的にダウンロードされます。

于 2012-09-22T14:21:26.963 に答える
0

JavaScript を使用してダウンロードを開始することはできません。この目的で AJAX を使用しないでください。docsx.phpスクリプトへの標準フォーム送信を使用します。

<form action="docsx.php" method="post">
    ... some input fields

    <input type="submit" value="Download" />
</form>
于 2012-09-22T14:23:18.213 に答える