如何从php中jquery创建的输入类型文本中获取数据
在我的程序中,用户可以通过单击按钮jquery创建。但是php不会将数据发送到另一个页面 jquery:如何从php中jquery创建的输入类型文本中获取数据,php,jquery,Php,Jquery,在我的程序中,用户可以通过单击按钮jquery创建。但是php不会将数据发送到另一个页面 jquery: $(document).ready(function(){ var counter = 2; $("#addButton").click(function () { if(counter>10){ alert("Only 10 textboxes allow"); return fals
$(document).ready(function(){
var counter = 2;
$("#addButton").click(function () {
if(counter>10){
alert("Only 10 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.after().html('<label>ویژگی '+ counter + ' : </label>' +
'<input type="text" name="txt' + counter +
'" id="textbox' + counter + '" class="form-control" style="margin:5px">');
newTextBoxDiv.appendTo("#TextBoxesGroup");
counter++;
});
});
php:
为什么不在IT中使用ajax?您尝试发送的变量是什么?这两段代码似乎完全独立。jQuery没有以任何方式调用PHP。您想发出一个ajax请求。将值保存到隐藏字段,然后获取服务器端。我已经尝试过ajax。php无法获取由jquery创建的数据
$x = 1;
while ($x<11)
{
$name = 'txt' . $x ;
if(isset($_POST[$name]) && $_POST[$name]!='')
{
object::object_Insert($_POST[$name],$s);
}
$x++;
}