Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用来自ajax加载函数的数据?_Ajax_Jquery - Fatal编程技术网

如何使用来自ajax加载函数的数据?

如何使用来自ajax加载函数的数据?,ajax,jquery,Ajax,Jquery,假设我有下面的代码。根据从下拉列表中选择的值,它将显示与该值关联的复选框。这部分工作得很好,除了在我提交表单时,没有加载来自ajax call process.php的数据。我在ViewSource中没有看到它,因此我无法将它们包含在 javascript Html process.php的代码片段 结果显示得很好,只是我不能在表单提交中使用复选框值 foreach($new as $r) { $svn_tag = rtrim($r['current_tag'], '/'); e

假设我有下面的代码。根据从下拉列表中选择的值,它将显示与该值关联的复选框。这部分工作得很好,除了在我提交表单时,没有加载来自ajax call process.php的数据。我在ViewSource中没有看到它,因此我无法将它们包含在

javascript

Html

process.php的代码片段

结果显示得很好,只是我不能在表单提交中使用复选框值

foreach($new as $r) {
    $svn_tag = rtrim($r['current_tag'], '/');
    echo "<tr>";
    echo "<td><label class='checkbox'><input name='tag[{$r['name']}]' type='checkbox' value='{$r['name']}'  /></label></td>";        
    echo "<td class='primary'>". ucfirst($r['name']) . "</td>";
    echo "<td class='primary'><input type='text' name='revision[{$r['name']}]' value='{$svn_tag}'></td>";
    echo "<td><input type='hidden' name='docroot[{$r['name']}]' value='{$r['docroot']}'></td>";
    echo "</tr>";
}

我选中该框,点击继续按钮,它失败了。也就是说,tag的值不会传递给下一个方法。基本上,如果您查看source,output div中不会显示任何内容。

能否提供process.php返回的代码示例?输出元素在哪里?我想这只是你的代码片段中缺少的,但更糟糕的是,我没有包括处理数据的方法,但是代码片段显示了它显示的内容。它可以工作,只是我不能在表单提交期间使用复选框。您是否试图将表行呈现给div?已添加。。。php基本上是加载到输出div中的。也许有更好的方法可以做到这一点?
<form method="post" id="myform">
<select id="dropdown" name="dropdown">
    <option value="QU">QU</option>
    <option value="QF">QF</option>
    <option value="QC">QC</option>
</select>

<div id="output"></div>
<button type="submit">Continue</button>
</form>
$(document).ready(function() {
    $('#dropdown').live("change", function() {
        $('#output').load('/process.php',{dropdown: $(this).val()});
    });
});
foreach($new as $r) {
    $svn_tag = rtrim($r['current_tag'], '/');
    echo "<tr>";
    echo "<td><label class='checkbox'><input name='tag[{$r['name']}]' type='checkbox' value='{$r['name']}'  /></label></td>";        
    echo "<td class='primary'>". ucfirst($r['name']) . "</td>";
    echo "<td class='primary'><input type='text' name='revision[{$r['name']}]' value='{$svn_tag}'></td>";
    echo "<td><input type='hidden' name='docroot[{$r['name']}]' value='{$r['docroot']}'></td>";
    echo "</tr>";
}
<input type="checkbox" name="tag" value="test">