jsonp
发布时间:2020-12-16 19:40:22 所属栏目:百科 来源:网络整理
导读:前台: $( "#getJsonpByJquery" ).click( function () { $.ajax({ url: 'http://localhost:2701/home/somejsonp' ,dataType: "jsonp" ,jsonp: "callback" ,// jsonp默认回调参数为callback success: function (data) { console.log(data) } })}) $.get( 'htt
前台: $("#getJsonpByJquery").click(function () { $.ajax({ url: 'http://localhost:2701/home/somejsonp',dataType: "jsonp",jsonp: "callback",//jsonp默认回调参数为callback success: function (data) { console.log(data) } }) }) $.get('http://localhost:2701/home/somejsonp',{ act: "searchType","str": str },function (data) { if (data && data.PTSchema) { if (data.PTSchema.length > 0) { html.push('<ul>'); $.each(data.PTSchema,function (i,item) { html.push("<li data-ptid='" + item.Id + "'>"); html.push("<a onclick='PTFullNameOnClick("" + item.Id + "","" + item.FulllName + "","")'>"); html.push(item.FulllName); html.push("</a>"); html.push("</li>"); }); } }},"jsonp")//jsonp默认回调参数为callback 后台: public override void ProcessRequest(HttpContext context) { context.Response.Write(searchType(dict["str"],dict["callback"])); } private string searchType(string s,string callback) { string str = callback + "()"; s = HttpUtility.UrlDecode(s); if (ptModels.Count > 0) { return callback + "(" + Json.ToJson<PTSchema>(ptModels) + ")"; } else { return str; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |