在Jquery中使用MsgBox,将信息传递给PHP并检索结果
正如您所见,我是jquery/javascript的noob,我需要传递变量以获取或发布表单,php的结果需要传递给jquery,我开始编写smthing,如下所示,但它不起作用 有人帮我吗在Jquery中使用MsgBox,将信息传递给PHP并检索结果,php,javascript,jquery,msgbox,Php,Javascript,Jquery,Msgbox,正如您所见,我是jquery/javascript的noob,我需要传递变量以获取或发布表单,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:&
// 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
//消息框的id和设置
$(“#注册表项”)。单击(函数(){
$.msgbox(“为了处理您的请求,您必须提供以下内容:”{
键入:“提示”,
投入:[
{键入:“文本”,标签:“插入您的姓名:”,值:“George”,必填项:true},
],
按钮:[
{类型:“提交”,值:“确定”},
{类型:“取消”,值:“退出”}
]
},//消息框的id和设置-结束
功能(名称){
//检查是否已设置名称字段
如果(姓名){
//将from字段传递到php$\u GET['name\u php']变量
$.get(“form.php”,{name\u php:name},
**//重写**
功能(数据){
如果(数据){
//内联数据创建/插入
$.msgbox($('#textbox').html(数据),{type:“info”});
}//如果数据结束
});//函数数据结束
**//重写**
}//如果名称结束
});//函数名结束
}); // 注册表单击
$。get
是一个异步函数调用,因此这意味着它下面的代码不会在处理后被编译为运行。$.get
调用中的回调函数应如下所示:
function(data) {
if (data){
// inline the data creation/insertion
$.msgbox($('#textbox').html(data), {type: "info"});
}
}
很简单,我确实重写了,但msgbox没有启动,有什么问题吗?