目标是调用一个方法,然后返回一个JSON对象.
我是JSON的新手.
我有一个default.aspx,其中包含以下代码.现在我希望Default.aspx.cs中的普通方法在这里的click事件上运行.
$(".day").click(function (event) {
var day = $(event.currentTarget).attr('id');
if (day != "") {
$.ajax(
{
type: "POST",
async: true,
url: 'Default.aspx?day=' + day,
data: day,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
console.log("SUCCESS:" + msg);
// $(".stripp img").attr('src', "data:image/jpg;" + msg);
// $(".stripp").show();
},
error: function (msg) {
console.log("error:" + msg);
}
});
}
Run Code Online (Sandbox Code Playgroud)
});
Default.aspx.cs看起来类似于:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["day"] != null)
GetFile(Request.QueryString["day"]);
}
public string GetFile(string day)
{
string json …Run Code Online (Sandbox Code Playgroud) 使用jQuery编写插件相对容易,只需使用$ .fn就可以了.像这样:
$.fn.analyse = function() {
...
}
Run Code Online (Sandbox Code Playgroud)
但是,如果你不能使用jQuery怎么办?
假设我希望能够使用以下代码:
document.querySelector("#mydiv").analyse();
Run Code Online (Sandbox Code Playgroud)
我可以这样做:
Object.prototype.analyse = function() {
...
}
Run Code Online (Sandbox Code Playgroud)
但据我所知,它是不受欢迎的!
我正在使用Angular UI路由器,我需要使用state.go方法发送参数.像这样:
$state.go('myState', { redirect : true });
Run Code Online (Sandbox Code Playgroud)
我还需要在事件stateChangeStart中检查该参数.像这样:
$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
//redirect parameter is not available here.
//should be in toParams right?
}
Run Code Online (Sandbox Code Playgroud)
编辑:这是我的statedefinition:
$stateProvider.state('customer.search', {
url: '/search',
views: {
"right-flyover@": {
templateUrl: 'customer/search/search.tpl.html',
controller: 'CustomerSearchCtrl'
}
},
data: {
pageTitle: 'Sök användare',
hidden: true
}
});
Run Code Online (Sandbox Code Playgroud) 在我管理的网站上,我们有几个.woff文件,每个字体一个.为了节省加载时间,我想减少发出的请求数量.是否可以将这些woff文件合并到一个资源中?
我有一个处理 certian 事件跟踪的函数,如下所示:
var trackAddress = function (providedProduct, searchedProduct) {
_trackEvent('Address found', providedProduct, searchedProduct);
}
Run Code Online (Sandbox Code Playgroud)
现在如果 searchedProduct 未定义或空字符串会发生什么?
问题是,在 Google Analytics 中,我可以看到所有事件操作的总和等于事件总数。事件标签并非如此。
这可能是什么原因?
ajax ×1
asp.net ×1
httprequest ×1
javascript ×1
jquery ×1
json ×1
prototype ×1
web ×1
webforms ×1
woff ×1