Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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
对.load(url)中的数据运行javascript函数_Javascript_Jquery_Function - Fatal编程技术网

对.load(url)中的数据运行javascript函数

对.load(url)中的数据运行javascript函数,javascript,jquery,function,Javascript,Jquery,Function,基本上,我有一个带有“tabbed”div的页面,当用户单击其中一个选项卡时,就会有一个.html页面加载到该div中。我想知道是否可以在从.load()javascript函数加载的新数据上运行JS函数 下面是加载新数据的函数 function switchAssetTabContent(tabContext, func, params) { $("#ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_tpAssetCla

基本上,我有一个带有“tabbed”div的页面,当用户单击其中一个选项卡时,就会有一个.html页面加载到该div中。我想知道是否可以在从.load()javascript函数加载的新数据上运行JS函数

下面是加载新数据的函数

    function switchAssetTabContent(tabContext, func, params) {
    $("#ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_tpAssetClassPrimary").html('<table width="375px" height="auto" style="min-height: 100px; height: auto; width: 260px;"><tr><td align="center" valign="middle"><img src="/backoffice/Prospects/App360/images/spinwait.gif" /></td></tr></table>');
    var url = "pageFragments/overview/" + tabContext + ".html";
    $("#ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_tpAssetClassPrimary").load( url +"?" + (new Date().getTime()), params, updateYesterday );
    }   
函数开关assettabcontent(tabContext、func、params){
$(“#ctl00_content placeholder 1_overview 1_tcAssetAllocation_tpAssetClassPrimary”).html(“”);
var url=“pageFragments/overview/”+tabContext+“.html”;
$(“#ctl00_content placeholder 1_overview 1_tcAssetAllocation_tpAssetClassPrimary”).load(url+“?”+(new Date().getTime()),参数,updateEyestDay);
}   
问题是加载的数据如下所示

<div bgcolor="white" id="ctl00_ContentPlaceHolder1_Overview1_pnlAssetClassAllocation">
    <table cellspacing="0" cellpadding="0" style="width: 375px;" border="0">
    <tr><td
        valign="top"
        style="background-color: white vertical-align: top; width: 175px"
        id="ctl00_ContentPlaceHolder1_Overview1_tdAssetClassChart">
        <div bgcolor="white" style="padding:0" id="AssetClassChartControlDiv" class="chart">
        </div>
        </td>
      <td valign="top">

        <div id="ctl00_ContentPlaceHolder1_Overview1_pnlAssetClassLegend">

          <input type="hidden" value="" name="ctl00xContentPlaceHolder1xOverview1xuwgAssetClassChartLegend" id="ctl00_ContentPlaceHolder1_Overview1_uwgAssetClassChartLegend" />
          <table cellspacing="0" cellpadding="0" border="0" style="overflow: hidden; position: relative;" id="ctl00xContentPlaceHolder1xOverview1xuwgAssetClassChartLegend_main">
              <tr id="ctl00xContentPlaceHolder1xOverview1xuwgAssetClassChartLegend_mr">
                <td align="left" style="vertical-align: top;">
                    <div id="AssetClassChartControl_legend" class="legend">
                    </div>
                </td>
              </tr>
          </table>

        </div>

</td></tr>
</table>

</div>

我在主页上编写了js函数,调用那些使用现在加载的html
s和
s的ID的信息。我可以把.js函数放在包含的页面上吗?我只是想我应该只在
标签中或
标签之外包含我的js函数。。。。。
非常感谢您的帮助。

如果您想重新运行
document.ready()
函数,可以将其设置为命名函数:

function myReadyFunction() { ... }

document.ready(myReadyFunction);
然后,您可以在调用
.load()
时使用它:


加载请求完成时,您已经在调用函数
updateeysterday
。您的
.load()
正在覆盖在它之前添加的表,您确定加载到了正确的位置吗?@Barmar:该表的唯一内容是
,所以可能是的。@bfavaretto这只是附加到正在加载的内容的url,您认为这就是导致我的数据现在显示的原因吗?我之所以感到困惑,是因为当我只是将.load()函数调用的页面的HTML添加到站点上时,它完美地呈现了数据,但当通过JS与.load()函数混淆时,什么也不显示。@Barmar,这只是一个旋转图标,表示正在加载的东西就是一切,它为用户提供了一些东西,以向他们显示正在呈现的数据
$("#ctl00_ContentPlaceHolder1_Overview1_tcAssetAllocation_tpAssetClassPrimary").load( url +"?" + (new Date().getTime()), params, myReadyFunction );