【问题标题】:MsgBox in Jquery, pass info to PHP and retrieve resultsJquery中的MsgBox,将信息传递给PHP并检索结果
【发布时间】:2011-05-18 15:13:40
【问题描述】:

如你所见,我是 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

【问题讨论】:

    标签: php javascript jquery msgbox


    【解决方案1】:

    $.get 是一个异步函数调用,因此这意味着它下面的代码在它被处理后不能保证运行。 $.get 调用中的回调函数应如下所示:

    function(data) {
        if (data){
            // inline the data creation/insertion
            $.msgbox($('#textbox').html(data), {type: "info"});
        }
    }
    

    【讨论】:

    • 简单,我确实重写了,但是msgbox没有启动,可能是什么问题?
    猜你喜欢
    • 2013-11-06
    • 1970-01-01
    • 2013-12-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    相关资源
    最近更新 更多