Tag: coffeescript

在实际的设备上的iOS JSON麻烦

出于某种原因,这可以在运行iOS 6+的模拟器上运行,但不能运行在运行iOS 5+的实际iPad上。 当我在iPad上运行我的应用程序,它给了我这个错误(和其他人)。 Error parsing JSON: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn't be completed. (Cocoa error 3840.)" (Badly formed object around character 316.) UserInfo=0x650260 {NSDebugDescription=Badly formed object around character 316.} JSON used is this (which is passed from Javascript): {"functionname":"setItem","args":{"key":"http://localhost:3000/assets/tasks/task.js","value":"function Task(){this.steps=new Array,this.completed=!1,this.loaded=!1,this.stepCount=-1,this.points=0,this.newpoints=0,this.prevpoints=0,this.circleGesture=!1,this.customGesture=!1,this.subtaskCounter=0,this.className=/"/"}(goes on for a while since it is a js script)"}} 在iOS中将jsonstring转换为json的代码 if […]

MobileSafari不会发回由CORS设置的Cookie

我在MobileSafari中加载了一个页面,通过CORS与另一台服务器进行通信。 在桌面浏览器(经过testing的Chrome和Safari)中,我可以login,获取会话cookie,并将该会话cookie发回给后续请求,以便我可以通过所有API调用进行身份validation。 但是,当我通过Mobile Safarilogin时,Cookie不会在后续请求中发回。 我使用Charles Proxy来监视发生了什么,它告诉我: POST https://myremoteserver.com/sessions.json传递我的login信息 它成功,并收到一个有效的Set-Cookie头的响应。 请求GET https://myremoteserver.com/checkout.json ,没有Cookie请求头。 服务器响应,如果我没有login。 我在Zepto.js使用这段代码来确保在XHR对象上正确设置withCredentials: true 。 (赦免咖啡) # Add withCredentials:true to the xhr object to send the remote server our cookies. xhrFactory = $.ajaxSettings.xhr $.ajaxSettings.xhr = -> xhr = xhrFactory.apply(this, arguments) xhr.withCredentials = yes xhr 这个片段在桌面浏览器中效果很好,在我添加之前,我无法在这些桌面浏览器中保留会话cookie。 MobileSafari中是否存在一些令桌面浏览器无法正常工作的问题? 为什么它不以同样的方式工作? 编辑! 这是我的轨道2.3应用程序,我相信相当标准的东西我的CORS头设置 def add_cors_headers if valid_cors_domain headers['Access-Control-Allow-Origin'] […]