使用AJAX加载动态内容

时间:2013-06-02 23:29:08

标签: jquery ajax smart-wizard

所以我通过我的控制器从PHP(服务(控制器)/ ajaxcontents(函数))加载内容。该函数从数据库生成动态表单字段,并将它们返回给向导。

它们输出如下:

    <input type="text" class="P_name" 
name="dataString[HS1_General_Information_label_1]" value="Jones Mike">

生成表单字段的Javascript

$(document).ready(function() {
// Initialize Smart Wizard with ajax content load and cache disabled
$('#wizard').smartWizard({contentURL:'services/ajaxcontents'
,contentCache:false});
 }); 

问题是我加载的内容无法识别。对于实例,我有一个动态加载class="data"的字段,一个简单的脚本无法识别该字段是否存在。

如何首先返回数据,然后根据返回的字段加载表单的验证?有点像ajax的完整回调?

1 个答案:

答案 0 :(得分:0)

智能向导文档:When a step got focus, the SmartWizard will post the step number to this contentURL and so you can write server side logic to format the content with the step number to be shown next. The response to this call should be 该步骤的内容 in HTML format.

所以,我想你不会发送带有标签的元素,而只发送内容。