我正在尝试将信息从 jquery 传递到数据库。
我在 jquery 中已经提交了该函数等,但不确定现在该去哪里。
我想要访问的 php 将请求数据,但我不确定是否会将我的数据传递到此页面?请不要//需要在此处添加一些内容?少量。
我知道我需要添加类似帖子之类的内容,但不确定如何使用 jquery 来做到这一点。
下面是 jquery 代码:
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 600,
width: 1000,
modal: true,
buttons: {
"Create Property": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
bValid = bValid && checkLength( name, "name", 3, 16 );
bValid = bValid && checkLength( email, "address1", 6, 80 );
bValid = bValid && checkLength( password, "address2", 5, 16 );
if ( bValid ) {
***//NEED TO ADD SOMETHING HERE?***
$( this ).dialog( "close" );
}
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
下面是我想要将数据传递到的 php 页面:
if(isset($_REQUEST['submit-property']))
{
//Create a new object
$property = new Property("");
//Collect the variables passed from REQUEST
$name = $_REQUEST['name'];
$address1 = $_REQUEST['address1'];
$address2 = $_REQUEST['address2'];
$address3 = $_REQUEST['address3'];
$address4 = $_REQUEST['address4'];
$postCode = $_REQUEST['postCode'];
etc etc etc
希望有人能帮忙。
非常感谢。
最佳答案
以jQuery的ajax函数为例:
$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
关于php - jquery 到 php 代码,然后到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19505534/