我的web.config文件中有这个namevaluesectionhandler,用于设置三个ajax部分视图的轮询时间:
I have this namevaluesectionhandler in my web.config file that sets the poll time of three ajax partial views:
<section name="PollIntervall" type="System.Configuration.NameValueSectionHandler"/> <PollIntervall> <add key="server_poll" value="20000"/> <add key="build_poll" value="5000"/> <add key="feed_poll" value="5000"/> </PollIntervall>
我试图引用这些,但我有一个方法在.js文件中执行ajax调用。关于我应该怎么做的任何想法? (我需要在脚本中切换出硬编码区间,并用web.config文件中的值替换它。)
I am trying to reference these, but I have the method that does the ajax call in a .js file. Any ideas on how I should go about doing this? (I need to switch out the hard coded intervals in my script, and replace it with the values from the web.config file.)
var ajaxFunctionMaker = function(callbackFillElementSelector, serverUrl, interval) { var ajaxfunc = function () { $.ajax({ type: 'GET', cache: false, accepts: 'application/json', success: function (partialView) { $(callbackFillElementSelector).html(partialView); //updateCounter(); $.event.trigger('ajaxreturn'); setTimeout(ajaxfunc, interval); }, error: function (jqXHR, textStatus, errorThrown) { //updateCounter(); }, url: serverUrl }); }; return ajaxfunc; }; ajaxFunctionMaker('#serverview', '/BuildMonitor/PollServer', 20000)(); ajaxFunctionMaker('#buildview', '/BuildMonitor/PollBuild', 5000)(); ajaxFunctionMaker('#feed', '/BuildMonitor/PollFeed', 5000)(); })();
推荐答案
正确的论坛是forums.asp。 The correct forum would be forums.asp.
更多推荐
在Web.config文件中添加Ajax轮询时间,并访问值?
发布评论