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 this. 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 = " + navBarS.Url); navBars.fetch({ data: {},type: 'GET',success: function(data,response,options) { window.logger.debug("NavBarView data = " + data); var compiledTemplate = _.template( htmlTemplate,{ items : data } ); $("#navBar").html(compiledTemplatE); },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(responsE) { window.logger.debug("getTing NavBars from response=" + responsE); return response; },sync: function(method,model,options){ options.timeout = 10000; //json mock //optionS.Url = 'http://localhost:9000/data' + "/navbars" + ".JSON"; //options.dataType = 'json'; //jsonp options.dataType = "jsonp"; options.crossDomain = true; optionS.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 / BrandCodE) { (apiVersion,brandCodE) => authenticate(BasicAuth(new BrandUserPassAuthenticator(dao),"Realm")) { user => path("products") { jsonpWithParameter("callBACk") { complete(httpBody(`application/json`,dao.db.withSession { logger.debug("HitTing the URI navbars with apiVersion=" + apiVersion + ",brandCode=" + brandCodE) DefaultJsonProtocol.listFormat[NavBar].write(dao.NavBars.all).toString } )) } } } } …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 + Jasmine + Phantom + Grunt + Bootstrap) come soon… References: integration http://hdnrnzk.me/2013/01/10/BACkbone-requirejs-jasmine-phantomjs-and-grunt/ https://github.com/ghiden/BACkbone-requirejs-jasmine-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,请注明来意。