在jquery ajax响应文件代码中调用javascript函数
我试图在ajax响应(wall_list.php)中调用date_cal()
javascript函数。每件事都很好,我得到了正确的响应。 但它没有调用date_cal()函数。
主文件:
$就({
url: 'wall_list.php', data:"dt_from="+dt_from+"&dt_to="+dt_to+"&week="+week+"&month="+month+"&dt_filter="+dt_filter+"&fan="+fan+"&gender="+gender+"&pageNumber="+pagenumber, type: 'POST', success: function (resp) { if(resp) { //alert(resp); document.getElementById('wall_listdiv').innerHTML=resp; }
Wall_list.php
一些代码……………….
> <td id="" class="tm_td" valign="top" colspan=2> > date_cal('',''); >
一些代码………………….
它不是在那里调用javascript。
任何人都可以解释如何回应所有这些function。
例如
PHP:
JS:
$.ajax({ url: 'wall_list.php', data:"dt_from="+dt_from+"&dt_to="+dt_to+"&week="+week+"&month="+month+"&dt_filter="+dt_filter+"&fan="+fan+"&gender="+gender+"&pageNumber="+pagenumber, type: 'POST', success: function (resp) { if(resp){ $('#wall_listdiv').html(date_cal(resp)); }
干得好
$.ajax({ url: 'wall_list.php', data: "dt_from="+dt_from+"&dt_to="+dt_to+"&week="+week+"&month="+month+"&dt_filter="+dt_filter+"&fan="+fan+"&gender="+gender+"&pageNumber="+pagenumber, type: 'POST', success: function (resp){ if(resp){ $("#wall_listdiv").html(resp); } }, dataType: 'html' });
你想要做的是,将return dataType
指定为html
。 来自jQuery API
If html is specified, any embedded JavaScript inside the retrieved data is executed before the HTML is returned as a string. Similarly, script will execute the JavaScript that is pulled back from the server, then return the script itself as textual data.
更多信息: jQuery.ajax() – jQuery API