1

ご覧のとおり、私はjquery / javascriptで初心者です。フォームで記述されたGETまたはPOSTに変数を渡す必要があり、phpの結果をjqueryに渡す必要があります。以下のようにsmthingを書き始めましたが、機能しません。

誰か助けてください

// id and settings for msg box

$("#registerin").click(function() {
  $.msgbox("<p>In order to process your request you must provide the following:</p>", {
    type    : "prompt",
    inputs  : [
      {type: "text",label: "Insert your Name:", value: "George", required: true},
    ],
    buttons : [
      {type: "submit", value: "OK"},
      {type: "cancel", value: "Exit"}
    ]
  }, // id and settings for msg box - end
   function(name) {
    // checking if name field has been set
    if(name) {
    // pass from field to php $_GET['name_php'] variable
      $.get("form.php", {name_php: name },
**// rewriten**
    function(data) {
    if (data){
        // inline the data creation/insertion
        $.msgbox($('#textbox').html(data), {type: "info"});
    } // if data end
  }); // function data end
**// rewriten**
    } // if name end
  }); // function name end

}); // registerin click
4

1 に答える 1

0

$.getは非同期関数呼び出しであるため、その下のコードは、処理された後に実行されることが保証されていません。呼び出し内のコールバック関数は次の$.getようになります。

function(data) {
    if (data){
        // inline the data creation/insertion
        $.msgbox($('#textbox').html(data), {type: "info"});
    }
}
于 2011-05-18T15:20:03.353 に答える