Json
发布时间:2022-04-22 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了SuperPlan(13)Winner Seller Server - JSONP Basic Auth,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
SuperPlan(13)Winner Seller Server - JSONP Basic Auth 15. Basic Auth on JSONP Server If we are using the basic auth,we can do the jsonp client like thi
s. Here is the View Controller of
BACkbone.js …snip... render: function()
{ window.logger.debug("I am going to hit the Nav Bar Template Page."
); var widget = this; var navBars = new NavBarsModel(
); window.logger.debug(" navBars url = " + navBar
S.Url
); navBar
s.fetch(
{ data:
{},type: 'GET',
success: function(data,response,options)
{ window.logger.debug("NavBarView data = " + data
); var compiledTemplate = _.template( htmlTemplate,
{ items : data }
); $("#navBar").html(compiledTemplat
E); },error: function(jqXHR,textStatus,errorThrown)
{ window.logger.error('error arguments: ',arguments
); window.logger.error(jqXHR + " " + textStatus + " " + errorThrown
); },complete: function(xhr,textStatus)
{ window.logger.debug(textStatus
); } }
); } …snip… Here is the Model Layer of
BACkbone.js …snip... var Items =
BACkbone.Collection.extend(
{ url: '/navbars',parse: function(respons
E) { window.logger.debug("get
Ting NavBars from response=" + respons
E); return response; },sync: function(method,model,options)
{ option
s.timeout = 10000; //json
mock //option
S.Url = '
http://localhost:9000/data' + "/navbars" + ".JSON"; //option
s.dataType = 'json'; //jsonp option
s.dataType = "jsonp"; option
s.crossDomain = true; option
S.Url = '
http://' + 'customer' + ':' + 'customer' + '@' + 'localhost:9002/v1/sillycat' + '/navbars'; return
BACkbone.sync(method,options
); } }
); …snip… It the server side,we also use jsonpwithParameter …snip... pathPrefix(Version / BrandCod
E) { (apiVersion,brandCod
E) => authenticate(BasicAuth(new BrandUserPassAuthenticator(dao),"Realm"))
{ user => path("products")
{ jsonpWithParameter("call
BACk")
{ complete(
httpBody(`application/json`,dao.db.withSession
{ logger.debug("Hit
Ting the URI navbars with apiVersion=" + apiVersion + ",brandCode=" + brandCod
E) DefaultJsonProtoco
l.listFormat[NavBar].write(dao.NavBar
s.all).to
String } )) } } } } …snip…
it is not nice and pretty to use POST in jsonp. So I will change
BACk to JSON for both the server side and client side. 16. JSON cross domain come soon... 17. Integration(
BACkbone +
require + Jas
mine + Phantom + Grunt + Bootstra
p) come soon… References: integration
http://hdnrnzk.me/2013/01/10/
BACkbone-
requirejs-jas
mine-phantomjs-and-grunt/
https://github.com/ghiden/
BACkbone-
requirejs-jas
mine-phantomjs-grunt-setup superplan 12
http://sillycat.iteye.com/blog/1881952
大佬总结
以上是大佬教程为你收集整理的SuperPlan(13)Winner Seller Server - JSONP Basic Auth全部内容,希望文章能够帮你解决SuperPlan(13)Winner Seller Server - JSONP Basic Auth所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。