Invalid State Error Ajax
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring invalid state error internet explorer developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Invalid State Error Xmlhttprequest
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; phantomjs invalid_state_err: dom exception 11 it only takes a minute: Sign up INVALID_STATE_ERR: DOM Exception 11 (WebKit) up vote 31 down vote favorite 11 I recently tested a Cappuccino app I was working on with Chrome and Safari. I get the error: INVALID_STATE_ERR: DOM
What Is Dom Exception 11
Exception 11: An attempt was made to use an object that is not, or is no longer, usable. The lack of information is frustrating. What object and where did I attempt to use it? Chrome tries to answer the second question but the line number it gives, 465, doesn't mean anything when the file it gives is just 94 lines long. Without more information I don't even know where to start looking. javascript dom webkit cappuccino share|improve this question dom exception 11 an attempt was made to use an object that is not or is no longer usable asked Aug 15 '10 at 18:35 Regis Frey 5151718 add a comment| 10 Answers 10 active oldest votes up vote 10 down vote accepted Chrome canary offers stack traces for DOM Exceptions! share|improve this answer answered Jun 16 '12 at 22:45 Jamie Pate 706712 1 This is the best answer to this question. Made my day. Thank you sir! –Nek Jun 25 '12 at 19:19 3 "DOM exceptions have stack trace in Chrome 21." code.google.com/p/chromium/issues/detail?id=64319 –Regis Frey Aug 17 '12 at 20:06 add a comment| up vote 52 down vote Usually this error occurs with the XMLHttpRequest when you call the open method with async = true, or you leave the async parameter undefined so it defaults to asynchronous, and then you access the status or responseText properties. Those properties are only available after you do a synchronous call, or on the readyState becoming ready (once the asynchronous call responds). I suggest you first try with async = false, and then switch to it being true and use the onReadyStateChange. share|improve this answer answered Mar 16 '11 at 0:24 Dave Lampert 597153 11 thanks buddy... I'd been rage-concentrating on this for an hour. –jsj Jun 15 '11 at 10:23 1 Instead of onReadyStateChange, use onLoad, if that's what you want. And status and responseText are actually available on HEADERS_RECIEVED state as well, so they are available early enough if you want it.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Invalid_state_err - 4
this site About Us Learn more about Stack Overflow the company Business Learn
Invalidstateerror Dom Exception 11 Xmlhttprequest
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question invalidstateerror javascript x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up http://stackoverflow.com/questions/3488698/invalid-state-err-dom-exception-11-webkit Android webapp Ajax exception `INVALID_STATE_ERR: DOM Exception 11` up vote 0 down vote favorite This is my first post on stack overflow, so I'll try to respect conventions and be as clear as possible. Introduction : For this project I'm trying to doing a web app with a local web server. My project is divide in two parts : Local web server which http://stackoverflow.com/questions/16934289/android-webapp-ajax-exception-invalid-state-err-dom-exception-11 transmit request to a real web server (it is a solution to resolve the Same origin policy) A android web app which is the view. It's where the problem occurred. When I'm trying to communicate with the server, using ajax request, the error INVALID_STATE_ERR: DOM Exception 11 occurred. However when I'm doing it on a firefox (with Apache), I haven't this problem. Local web server : The web server only stock or transmit data between web app and web server. Webapp : Initialization In my android activity I'm starting my web app like that : webview = new WebView(this); MyJavaScriptInterface myJavaScriptInterface = new MyJavaScriptInterface(this); webview.addJavascriptInterface(myJavaScriptInterface, "AndroidFunction"); // set settings webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setAppCacheEnabled(false); webview.setHorizontalScrollBarEnabled(false); webview.setVerticalScrollBarEnabled(false); if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) // 16 { // yourwebview, i use phonegap here webview.getSettings().setAllowUniversalAccessFromFileURLs(true); webview.getSettings().setAllowFileAccessFromFileURLs(true); } // start uri = new URI("http://127.0.0.1:"+LocalServer.RECORDING_PORT+"/index.html"); webview.loadUrl(uri.toString()); Ajax To save the data in my webapp I'm doing a basic XMLHttpRequest (also tried with JQuery but no message came out) function saveObject(in_strAction, in_oData, fctCallback) { var l_strURL = 'http://127.0.0.1:8888/api/' + in_strAction; var xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { try // line 46 { console.log ("xmlhttp.readyState="+xmlhttp.readyState+" && xmlhttp.status="+xmlhttp.status); if (xmlhttp.readyState==4 && xmlhtt
Sign in Pricing Blog Support Search GitHub This repository Watch 570 Star 11,494 Fork 3,004 madrobby/zepto https://github.com/madrobby/zepto/issues/921 Code Issues 38 Pull requests 16 Projects 0 Pulse Graphs New issue withCredentials on ajax causes INVALID_STATE_ERR: DOM Exception 11 #921 Closed LoeiFy opened this Issue Feb 10, 2014 · 3 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 3 participants LoeiFy commented Feb dom exception 10, 2014 i use basket.js : * http://addyosmani.github.io/basket.js/ for my page and use zepto for ajax width CORS _load: function(type, url, data, func) { try { $.ajax({ type: type, url: url, beforeSend: function(xhr) { xhr.withCredentials = true }, data: data, cache: false, timeout: 5000, success: function(data) { func(data) }, error: function() { dom exception 11 alert('error') } }); } catch (e) { alert(e) } } it is OK in PC chrome . but in android webview the page throw an error INVALID_STATE_ERR: DOM Exception 11 finally i found this Therefore, use the open method on the XMLHttpRequest object before setting the withCredentials attribute. http://www.w3.org/TR/XMLHttpRequest2/#the-withcredentials-attribute this will throw INVALID_STATE_ERR: DOM Exception 11 : var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.open("POST", "url", true); xhr.send(); OK : var xhr = new XMLHttpRequest(); xhr.open("POST", "url", true); xhr.withCredentials = true; xhr.send(); so i change zepto source code original : // ... if (settings.headers) for (name in settings.headers) setHeader(name, settings.headers[name]) xhr.setRequestHeader = setHeader xhr.onreadystatechange = function(){ if (xhr.readyState == 4) { xhr.onreadystatechange = empty clearTimeout(abortTimeout) var result, error = false if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) { dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type')) result = xhr.responseText try { // http://perfectio