[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Thank you very much !!! Without *addHeader* the following code only worked on IE, but adding this line also works in Chrome and Firefox. The problem was Chrome and Firefox html page didn't receive xmlhttp.status == 200, only xmlhttp.readyState == 4, only received status == 0. public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{ *response.addHeader(Access-Control-Allow-Origin, *);* PrintWriter out = response.getWriter(); java.util.Date today = new java.util.Date(); out.write(html\n + body\n + h1 align=centerEjemplo1 de Servlet/h1\n + br\n + today + /body\n+ /html ); } -- Pam On Tuesday, March 16, 2010 1:08:00 PM UTC-4, Ronen wrote: Excellent. Thanks very much T.J.. your idea worked. In my servlet, I overrided the doOptions() method from HttpServlet and returned the response headers that you suggested: response.addHeader(Access-Control-Allow-Origin, *); response.addHeader(Access-Control-Allow-Methods, request.getHeader(Access-Control-Request-Methods)); response.addHeader(Access-Control-Allow-Headers, request.getHeader(Access-Control-Request-Headers)); and Firefox and Chrome both started working beautifully (also verified that IE still works). In the end, my overall intent is to package this HTML file with my web application, so it sounds like I won't need to have this doOptions() in my servlet. It's just that in the beginning, I figured I would test the HTML file outside of the web app and I guess I didn't realize I would run into this kind of trouble. Still, it's always good to know how to go about fixing something like this in the future. Thanks for everyone's help. --Ronen -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To unsubscribe from this group and stop receiving emails from it, send an email to prototype-scriptaculous+unsubscr...@googlegroups.com. To post to this group, send email to prototype-scriptaculous@googlegroups.com. Visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[Proto-Scripty] Re: Ajax.request problem
Hello Akaballa Well as long as I understand prototype ajax request you need to add asynchronous: false, in you ajax request definition. So try like this: new Ajax.Request('some url', { asynchronous: false, method:'post', parameters: {searchString: searchQuery}, onSuccess: function(transport) { var str = transport.responseText || no response text; $('searchResponse').update(str); }, onFailure: function() { alert('Unable to retrieve requested data. Please try again.'); } }); Let me know if it still creates problem for you. On Wednesday, 22 October 2008 19:49:30 UTC+5:30, akaballa wrote: Well I implemented what you said and debugged my code through firebug and found out that the request is not sent because of the following error: Prototype is not defined dispatchException()Prototype.js (line 1355) respondToReadyState()Prototype.js (line 1322) onStateChange()Prototype.js (line 1249) bind()Prototype.js (line 214) [Break on this error] (this.options.onException || Prototype.emptyFunction)(this, exception); i did not make any changes to the prototype.js file. So I have no idea what the problem is. On Oct 22, 8:18 am, Baglan baglan@gmail.com wrote: I see an error in your code which could have prevented it from working at all; the ',' (comma) after the onSuccess function definition is missing (happens to me all to frequently :)) - could that be the issue or is it a typo? I'd suggest you to use some kind of debugger for spotting that kind of issues. Personally, I'm using FireBug for Firefox - it shows if there were any Javascript errors and lets you inspect AJAX requests easily. - Baglan p.s. Here's the link for the Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843 -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/W8Rbn15ThIwJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Ajax.Request fails, while vanilla XHR works fine
It seems to be an issue on their server (BaseHTTP/0.3 Python/2.7.1+ according to FireBug). I'll file a bug and see what happens. XHR without setRequestHeader sends usual 'GET' request: Request URL: http://zip.elevenbasetwo.com/?zip=a Request Method: GET Status Code: 404 Not Found *Request Headers* Accept: */* Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3 Accept-Encoding: gzip,deflate,sdch Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 Connection: keep-alive Host: zip.elevenbasetwo.com Origin: https://groups.google.com User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19 *Response Headers* Access-Control-Allow-Origin: * Connection: close Content-Type: text/plain Date: Fri, 13 Apr 2012 09:16:07 GMT Server: BaseHTTP/0.3 Python/2.7.1+ XHR with any setRequestHeader sends first 'OPTIONS' request (so-called preflighthttps://developer.mozilla.org/En/HTTP_Access_Control#Preflighted_requests ): Request URL: http://zip.elevenbasetwo.com/?zip=a Request Method: OPTIONS Status Code: 501 Not Implemented *Request Headers* Accept: */* Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3 Accept-Encoding: gzip,deflate,sdch Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 Access-Control-Request-Headers: x-xxx, origin Access-Control-Request-Method: GET Connection: keep-alive Host: zip.elevenbasetwo.com Origin: https://groups.google.com User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19 *Response Headers* Connection: close Content-Type: text/html Date: Fri, 13 Apr 2012 09:20:32 GMT Server: BaseHTTP/0.3 Python/2.7.1+ It seems that some browsers (like Firefox and WebKit-based) may send CORS requests without preflight for text/plain resources when no additional headers are set. In other cases they send preflighted 'OPTIONS' request, which is not implemented in this 'BaseHTTP/0.3 Python/2.7.1+' server. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/6xIQrvgSIqsJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Ajax.Request fails, while vanilla XHR works fine
Thanks very much for the added detail. I filed an issue on the Github project for the Python server, and within hours another Githubber had posted a pull request fixing the bug. The server was just not aware of what to do if it got such an OPTIONS request, so it was falling over. Walter On Apr 13, 2012, at 5:26 AM, Victor wrote: It seems to be an issue on their server (BaseHTTP/0.3 Python/2.7.1+ according to FireBug). I'll file a bug and see what happens. XHR without setRequestHeader sends usual 'GET' request: Request URL: http://zip.elevenbasetwo.com/?zip=a Request Method: GET Status Code: 404 Not Found Request Headers Accept: */* Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3 Accept-Encoding: gzip,deflate,sdch Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 Connection: keep-alive Host: zip.elevenbasetwo.com Origin: https://groups.google.com User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19 Response Headers Access-Control-Allow-Origin: * Connection: close Content-Type: text/plain Date: Fri, 13 Apr 2012 09:16:07 GMT Server: BaseHTTP/0.3 Python/2.7.1+ XHR with any setRequestHeader sends first 'OPTIONS' request (so-called preflight): Request URL: http://zip.elevenbasetwo.com/?zip=a Request Method: OPTIONS Status Code: 501 Not Implemented Request Headers Accept: */* Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3 Accept-Encoding: gzip,deflate,sdch Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 Access-Control-Request-Headers: x-xxx, origin Access-Control-Request-Method: GET Connection: keep-alive Host: zip.elevenbasetwo.com Origin: https://groups.google.com User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19 Response Headers Connection: close Content-Type: text/html Date: Fri, 13 Apr 2012 09:20:32 GMT Server: BaseHTTP/0.3 Python/2.7.1+ It seems that some browsers (like Firefox and WebKit-based) may send CORS requests without preflight for text/plain resources when no additional headers are set. In other cases they send preflighted 'OPTIONS' request, which is not implemented in this 'BaseHTTP/0.3 Python/2.7.1+' server. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/6xIQrvgSIqsJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request fails, while vanilla XHR works fine
Same browser (Safari.latest) on the same computer, the Prototype method gives me a security failure (Origin [my host] is not allowed by Access-Control-Allow-Origin.) while the long-hand XHR (inside a Prototype observer) just works without any comment: Two differences I can notice: 1. Prototype sets request headers 'X-Requested-With', 'X-Prototype-Version', 'Accept' with setRequestHeaders() - you don't 2. Prototype calls send with null argument this.transport.send(null); // Prototype vs client.send(); // your raw XHR If you can test your code with these two changes - will it raise error? $('zip').observe('change', function(evt) { var client = new XMLHttpRequest(); client.open(GET, http://zip.elevenbasetwo.com?zip=http://zip.elevenbasetwo.com/?zip= + $F(this), true); client.onreadystatechange = function() { if(client.readyState == 4) { var data = client.responseText.evalJSON(); $('city').setValue(data.city); $('state').setValue(data.state); }; }; *client.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); client.setRequestHeader('X-Prototype-Version', '1.7'); * *client.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*');* client.send(*null*); }); -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/6dUgLVmeJQkJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request fails, while vanilla XHR works fine
Is header 'Access-Control-Allow-Origin' present in responses for both examples? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/99KTZ-IvHG8J. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Ajax.Request fails, while vanilla XHR works fine
On Apr 12, 2012, at 12:14 PM, Victor wrote: Same browser (Safari.latest) on the same computer, the Prototype method gives me a security failure (Origin [my host] is not allowed by Access-Control-Allow-Origin.) while the long-hand XHR (inside a Prototype observer) just works without any comment: Two differences I can notice: 1. Prototype sets request headers 'X-Requested-With', 'X-Prototype-Version', 'Accept' with setRequestHeaders() - you don't 2. Prototype calls send with null argument this.transport.send(null); // Prototype vs client.send(); // your raw XHR If you can test your code with these two changes - will it raise error? $('zip').observe('change', function(evt) { var client = new XMLHttpRequest(); client.open(GET, http://zip.elevenbasetwo.com?zip=; + $F(this), true); client.onreadystatechange = function() { if(client.readyState == 4) { var data = client.responseText.evalJSON(); $('city').setValue(data.city); $('state').setValue(data.state); }; }; client.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); client.setRequestHeader('X-Prototype-Version', '1.7'); client.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*'); client.send(null); }); Thanks very much for the suggestion. It looks as though ANY setRequestHeader invocation at all is enough to scuttle the request. I tried commenting one, then two, then all of them out. Without those three lines, the request works fine -- even with the null in the send. But add any one of them back, and the request fails. It seems to be an issue on their server (BaseHTTP/0.3 Python/2.7.1+ according to FireBug). I'll file a bug and see what happens. Walter -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Ajax.Request fails, while vanilla XHR works fine
I understand the SOP, I was wondering why it worked when I violated SOP from a hard-coded XHR request. Under the hood, it is my understanding that Prototype sets up a very similar XHR request anyway. It doesn't make any sense that the one would work while the other did not. This server is specifically kinked to allow a request such as this, or else the SOP would cause it to fail no matter what. Can anyone point out the flaw in my logic here? Walter On Apr 11, 2012, at 9:00 PM, Jason wrote: Have you tried to just use new Ajax.Request('index.php', .); vs the full URL from the Ajax.Request source code * - url (String): The URL to fetch. When the _same-origin_ policy is in * effect (as it is in most cases), `url` **must** be a relative URL or an * absolute URL that starts with a slash (i.e., it must not begin with * `http`). On Apr 10, 7:52 pm, Walter Lee Davis wa...@wdstudio.com wrote: Typo, fixed; still fails, same error, before ever reaching this line. On Apr 10, 2012, at 10:50 PM, Walter Lee Davis wrote: var data = responseText.evalJSON(); s/b var data = transport.responseText.evalJSON(); Walter -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request not working with HTTPS and self signed certificates
Hi, I don't think it has anything to do with the certificate being self- signed, just that it's https. Are you trying to use https in an ajax call when the page has been loaded via http? If so, you're running into the Same Origin Policy[1], which forbids doing that. Ajax requests, by default, can only go to the same origin as the document in which the script is running, and the concept of an origin includes the protocol (http://example.com and https://example.com are _different_ origins). More in the link. If you're in control of the server, you have a couple of options: 1. Use JSON-P[2] instead of Ajax. JSON-P doesn't have an origin restriction, but it can only use the GET method, not POST. 2. If you can rely on using a modern browser, you can use the new CORS[3] standard. You can see a list of browsers and their support (or lack thereof) for CORS here[4]. Unfortunately, CORS is only supported by IE in IE8 and above, and that support requires extra work (whereas every other browser vendor who supported it did so in a backward- compatible way). Specifically, instead of using XMLHttpRequest (which is what Ajax.Request uses), you have to use a completely new XDomainRequest object instead. But again, only on IE. Note that using CORS requires that you add support for it to the server, because you have to handle a request from the browser asking if it's okay to send the cross-origin request. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com [1] http://en.wikipedia.org/wiki/Same_origin_policy [2] http://en.wikipedia.org/wiki/JSONP#JSONP [3] http://www.w3.org/TR/access-control/ [4] http://caniuse.com/#search=cors On Jun 12, 9:00 am, Rick Avner rickav...@gmail.com wrote: Hi, I have a HTML Application (HTA) using Ajax.Request to get information from one of my LAMP based server. The requests were working fine using HTTP. However, the requests are failing (responseText is blank) when I use HTTPS. Server SSL is enabled using self signed certificates. Is there any way to ignore certificate warnings while using Ajax.Request? I know I should use CA certified certificates on my server. However just wondering if there is any way for Ajax.Request to work with self signed certificates. I am using prototype.js version 1.5. Thanks in advance. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request not working with HTTPS and self signed certificates
Hi, As I said in my post, the Ajax.Request call are in a HTML Application (HTA). Which is not a server page. It run on client machine using mshta.exe and request data from server using ajax. Ah, sorry. Probably not safe to assume everyone knows what you mean by HTA. I've seen any number of acronyms people have created ad hoc to make their web apps sound cool, I have to assume I put your use of HTA in that category, not being familiar with that specific Microsoft-centric technology. And I don't think the issue is due to Same Origin Policy, as the requests are working fine when server SSL is enabled using trusted certificate. In that case, it's a question for Microsoft. Prototype isn't involved in the certificate chain process at all. It just does the request and reads the response via XMLHttpRequest. The certificate stuff is handled by the user agent (e.g., mshta.exe). -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 12, 7:17 pm, Rick Avner rickav...@gmail.com wrote: Hi Crowder, Thanks for the information. As I said in my post, the Ajax.Request call are in a HTML Application (HTA). Which is not a server page. It run on client machine using mshta.exe and request data from server using ajax. And I don't think the issue is due to Same Origin Policy, as the requests are working fine when server SSL is enabled using trusted certificate. The response is blank when server SSL is enabled using self signed certificate. Any idea? And yes, I should try with latest version of prototype.js. Thanks On Jun 12, 3:05 pm, T.J. Crowder t...@crowdersoftware.com wrote: Addendum: I am using prototype.js version 1.5. Why? It's been out of date for more than three and a half years (assuming you're talking about v1.5.1.2, which was superceded by v1.6.0 in November 2007). That's a _long_ time in the browser-based world. -- T.J. On Jun 12, 10:36 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I don't think it has anything to do with the certificate being self- signed, just that it's https. Are you trying to use https in an ajax call when the page has been loaded via http? If so, you're running into the Same Origin Policy[1], which forbids doing that. Ajax requests, by default, can only go to the same origin as the document in which the script is running, and the concept of an origin includes the protocol (http://example.comandhttps://example.comare_different_origins). More in the link. If you're in control of the server, you have a couple of options: 1. Use JSON-P[2] instead of Ajax. JSON-P doesn't have an origin restriction, but it can only use the GET method, not POST. 2. If you can rely on using a modern browser, you can use the new CORS[3] standard. You can see a list of browsers and their support (or lack thereof) for CORS here[4]. Unfortunately, CORS is only supported by IE in IE8 and above, and that support requires extra work (whereas every other browser vendor who supported it did so in a backward- compatible way). Specifically, instead of using XMLHttpRequest (which is what Ajax.Request uses), you have to use a completely new XDomainRequest object instead. But again, only on IE. Note that using CORS requires that you add support for it to the server, because you have to handle a request from the browser asking if it's okay to send the cross-origin request. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com [1]http://en.wikipedia.org/wiki/Same_origin_policy [2]http://en.wikipedia.org/wiki/JSONP#JSONP [3]http://www.w3.org/TR/access-control/ [4]http://caniuse.com/#search=cors On Jun 12, 9:00 am, Rick Avner rickav...@gmail.com wrote: Hi, I have a HTML Application (HTA) using Ajax.Request to get information from one of my LAMP based server. The requests were working fine using HTTP. However, the requests are failing (responseText is blank) when I use HTTPS. Server SSL is enabled using self signed certificates. Is there any way to ignore certificate warnings while using Ajax.Request? I know I should use CA certified certificates on my server. However just wondering if there is any way for Ajax.Request to work with self signed certificates. I am using prototype.js version 1.5. Thanks in advance. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Ajax.Request not working with HTTPS and self signed certificates
Hate to butt in here but did try setting an alert(ajax.transport.responseText) right after your ajax call? On Sun, Jun 12, 2011 at 6:28 PM, T.J. Crowder t...@crowdersoftware.comwrote: Hi, As I said in my post, the Ajax.Request call are in a HTML Application (HTA). Which is not a server page. It run on client machine using mshta.exe and request data from server using ajax. Ah, sorry. Probably not safe to assume everyone knows what you mean by HTA. I've seen any number of acronyms people have created ad hoc to make their web apps sound cool, I have to assume I put your use of HTA in that category, not being familiar with that specific Microsoft-centric technology. And I don't think the issue is due to Same Origin Policy, as the requests are working fine when server SSL is enabled using trusted certificate. In that case, it's a question for Microsoft. Prototype isn't involved in the certificate chain process at all. It just does the request and reads the response via XMLHttpRequest. The certificate stuff is handled by the user agent (e.g., mshta.exe). -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 12, 7:17 pm, Rick Avner rickav...@gmail.com wrote: Hi Crowder, Thanks for the information. As I said in my post, the Ajax.Request call are in a HTML Application (HTA). Which is not a server page. It run on client machine using mshta.exe and request data from server using ajax. And I don't think the issue is due to Same Origin Policy, as the requests are working fine when server SSL is enabled using trusted certificate. The response is blank when server SSL is enabled using self signed certificate. Any idea? And yes, I should try with latest version of prototype.js. Thanks On Jun 12, 3:05 pm, T.J. Crowder t...@crowdersoftware.com wrote: Addendum: I am using prototype.js version 1.5. Why? It's been out of date for more than three and a half years (assuming you're talking about v1.5.1.2, which was superceded by v1.6.0 in November 2007). That's a _long_ time in the browser-based world. -- T.J. On Jun 12, 10:36 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I don't think it has anything to do with the certificate being self- signed, just that it's https. Are you trying to use https in an ajax call when the page has been loaded via http? If so, you're running into the Same Origin Policy[1], which forbids doing that. Ajax requests, by default, can only go to the same origin as the document in which the script is running, and the concept of an origin includes the protocol (http://example.comandhttps://example.comare_different_origins). More in the link. If you're in control of the server, you have a couple of options: 1. Use JSON-P[2] instead of Ajax. JSON-P doesn't have an origin restriction, but it can only use the GET method, not POST. 2. If you can rely on using a modern browser, you can use the new CORS[3] standard. You can see a list of browsers and their support (or lack thereof) for CORS here[4]. Unfortunately, CORS is only supported by IE in IE8 and above, and that support requires extra work (whereas every other browser vendor who supported it did so in a backward- compatible way). Specifically, instead of using XMLHttpRequest (which is what Ajax.Request uses), you have to use a completely new XDomainRequest object instead. But again, only on IE. Note that using CORS requires that you add support for it to the server, because you have to handle a request from the browser asking if it's okay to send the cross-origin request. HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com [1]http://en.wikipedia.org/wiki/Same_origin_policy [2]http://en.wikipedia.org/wiki/JSONP#JSONP [3]http://www.w3.org/TR/access-control/ [4]http://caniuse.com/#search=cors On Jun 12, 9:00 am, Rick Avner rickav...@gmail.com wrote: Hi, I have a HTML Application (HTA) using Ajax.Request to get information from one of my LAMP based server. The requests were working fine using HTTP. However, the requests are failing (responseText is blank) when I use HTTPS. Server SSL is enabled using self signed certificates. Is there any way to ignore certificate warnings while using Ajax.Request? I know I should use CA certified certificates on my server. However just wondering if there is any way for Ajax.Request to work with self signed certificates. I am using prototype.js version 1.5. Thanks in advance. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to
[Proto-Scripty] Re: Ajax.Request with an incorrect Header
I have done some research. You are right : It's not a problem with Prototype. Firefox sent a preflighted OPTION request according to CORS specification because I have added an custom header field. Do you know how to send my GET request with my custom header field ? I need to configure HTTP server, or browser, or other... ? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request with an incorrect Header
Hi, What you've quoted here: Access-Control-Request-Headers=remote_user,x-prototype-version,x- ...isn't a request header. It looks like a response header from a server that accepts CORS[1] requests and (for its own reasons) decided to make your request headers all lowercase. I just tried your code with Prototype 1.7 (http://jsbin.com/ikere3), and the actual *request* header sent (according to Chrome, and separately according to Firebug), was indeed REMOTE_USER with the value I gave (foo, in my case). [1] http://www.w3.org/TR/access-control/ HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Feb 23, 3:22 pm, RudyWI rudywi.de...@gmail.com wrote: Hi, I'am trying to use Ajax.Request to send a GET request with specific values in header part. I use the following code : function sendMyRequest(url, user) { var myAjax = new Ajax.Request(url, { method: 'get', requestHeaders: { REMOTE_USER:user }, onSuccess: function() { alert(OK); }, onFailure: function() { alert(KO); } }); } After I invoked this function, the request header sent is : Host=* ... Access-Control-Request-Method=GET Access-Control-Request-Headers=remote_user,x-prototype-version,x- requested-with So I don't have a valid field for REMOTE_USER, as defined in my function. I want a request Header similar to : Host=* ... REMOTE_USER=user How to do it ? Thanks -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request bug using IE 7 and Prototype 1.7
Sorry, you're right. the code posted is incorrect. the right one is: function otherFunc(o){ [.] }; function ajaxCall(url, callbackResponse_1, p) { try{ new Ajax.Request(url, { method: 'get', asynchronous: true, onSuccess: function(transport) { otherFunc(p); callbackResponse_1(); } }); } catch (exception) { alert(exception.inspect()); } } ..anyway onSucces never got reached because Ajax.request simply die after onCreate().To be more precise I had a JSP page including three script tag: scriptprototype.js/script scriptajaxCall.js/script, which contains the ajaxCall() and the otherFunc() functions above. script{inline_script}/script, which contains a function search() that calls ajaxCall(url,callbackResponse_1,p) and, of course, function callbackResponse_1() itself. After that there's an anchor in the page's form with javascript:search(); in its onClick attribute. Please consider that I didn't write this page by myself (..I think, for other thousands good reasons, that it is really a messy JSP!!!) I'm just bugfixing it. The fact is that the page won't work if simply import prototype.js on IE7 (7.0.5730.13), but it works on FF (3.6.12) and IE 8. The only ways that I found out to get it work are: - moving function() {return new XMLHttpRequest() and the end of the Try.these statement in prototype code (it works in ANY browser i tried). - disable native XMLHttpRequest support from IE7 advanced options (but as you easily understand I can't force users to disable a browser option to use my page.. :-| ). Any other suggestion? On 2 Dic, 00:05, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Your code, as quoted, assumes that the symbols `callbackResponse_1` and `callbackResponse_2` are defined by a scope enclosing your [.] -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request bug using IE 7 and Prototype 1.7
Hi, Sorry, you're right. the code posted is incorrect. the right one is: I haven't bothered to try it, but I'm not seeing anything in that code that would pose a problem. Unless you can put together a minimal, self-contained example, I don't think anyone is going to be able to help you. I don't think the fact it's JSP has anything to do with it (unless, of course, the JSP isn't outputting the HTML you expect -- but that's nothing to do with Prototype). Any other suggestion? Just to create a self-contained example and post it somewhere. Good luck, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 2, 2:24 pm, A.B. alessandro.bramb...@gmail.com wrote: Sorry, you're right. the code posted is incorrect. the right one is: function otherFunc(o){ [.] }; function ajaxCall(url, callbackResponse_1, p) { try{ new Ajax.Request(url, { method: 'get', asynchronous: true, onSuccess: function(transport) { otherFunc(p); callbackResponse_1(); } }); } catch (exception) { alert(exception.inspect()); } } ..anyway onSucces never got reached because Ajax.request simply die after onCreate().To be more precise I had a JSP page including three script tag: scriptprototype.js/script scriptajaxCall.js/script, which contains the ajaxCall() and the otherFunc() functions above. script{inline_script}/script, which contains a function search() that calls ajaxCall(url,callbackResponse_1,p) and, of course, function callbackResponse_1() itself. After that there's an anchor in the page's form with javascript:search(); in its onClick attribute. Please consider that I didn't write this page by myself (..I think, for other thousands good reasons, that it is really a messy JSP!!!) I'm just bugfixing it. The fact is that the page won't work if simply import prototype.js on IE7 (7.0.5730.13), but it works on FF (3.6.12) and IE 8. The only ways that I found out to get it work are: - moving function() {return new XMLHttpRequest() and the end of the Try.these statement in prototype code (it works in ANY browser i tried). - disable native XMLHttpRequest support from IE7 advanced options (but as you easily understand I can't force users to disable a browser option to use my page.. :-| ). Any other suggestion? On 2 Dic, 00:05, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Your code, as quoted, assumes that the symbols `callbackResponse_1` and `callbackResponse_2` are defined by a scope enclosing your [.] -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request bug using IE 7 and Prototype 1.7
Hi, Your code, as quoted, assumes that the symbols `callbackResponse_1` and `callbackResponse_2` are defined by a scope enclosing your ajaxCall function, as the code you quoted doesn't define them anywhere but the `onSuccess` handler tries to call them. When those symbols are defined (http://jsbin.com/asate3), the code works (including on IE7). When they aren't defined (http://jsbin.com/asate3/2), it fails (with all the browsers I tested -- Chrome, Mozilla, Opera, IE6, IE8...), which makes sense as you're trying to call functions that don't exist. If you set it up to actually call the `callbackResponse` passed into it (http://jsbin.com/asate3/3), it succeeds in calling that (including on IE7) and then fails (of course) to call the non-existant function callbackResponse_1. Nothing whatsoever to do with XMLHttpRequest. Or Prototype. Am I missing something? -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 1, 4:04 pm, A.B. alessandro.bramb...@gmail.com wrote: Hello everbody! I want to tell you about a funny error I've found making an Ajax.Request with Internet Explorer 7 and Prototype 1.7. Please. considering this very standard code: function ajaxCall(url, callbackResponse) { try{ new Ajax.Request(url, { method: 'get', asynchronous: true, onSuccess: function(transport) { callbackResponse_1(); callbackResponse_2(); } }); } catch (exception) { alert(exception.inspect()); } } When trying to execute those lines the Ajax.Request never happened, not only the callback method, even the very first transport.send(url) never starts. Googling and debugging a bit, I've found out the root of my problem: Basically the cause of bug is the well know poor designed XMLHttpRequest implementation of IE7 which is really buggy ad won't work as we expected. Anyway there's is also a prototype issue. In fact in version 1.7 sources there are these lines of code: var Ajax = { getTransport: function() { return Try.these( function() {return new XMLHttpRequest()}, --- function() {return new ActiveXObject('Msxml2.XMLHTTP')}, function() {return new ActiveXObject('Microsoft.XMLHTTP')} ) || false; }, [..] that try to create XMLHttpRequest object in a browser-compatibility way. Anyway because IE7 supports XMLHttpRequest, but it's buggy, those lines force it to use a buggy implementation instead of less-good-but- working Activex one. I wouldn't call it a prototype bug but it's a fact that at least one old version (I've seen it on 1.4) had a slightly different implementation: var Ajax = { getTransport: function() { return Try.these( function() {return new ActiveXObject('Msxml2.XMLHTTP')}, function() {return new ActiveXObject('Microsoft.XMLHTTP')}, function() {return new XMLHttpRequest()} --- ) || false; }, which perfectly works with different browser (IE 7/8, FF3, Chrome for sure). I hope that my post will be of help for someone else. Best Regards. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.request with enctype:multipart/form-data
I had an AJAX file upload solution built out, where you use javascript to create a hidden iframe element, then you set the form to post to that hidden frame. It worked, however if you go through the trouble of that i would recommend you opt for a flash based file uploader. Much more robust and can give you a multiple file upload functionality. On Jun 4, 2:46 am, Peter De Berdt peter.de.be...@pandora.be wrote: On 04 Jun 2010, at 00:57, jon...@gmail.com wrote: I want to send a form with the enctype as multipart/form-data using the prototype ajax.request how can I do it? If you want file upload using Ajax, google for AJAX file upload. You basically can't do it due to Javascript security and have to rely on either an iFrame to post the form data to or a Flash-based solution. You could also wait a couple more years until the HTML5 File API is implemented across all browsers :-) Best regards Peter De Berdt -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request and evalJS bug
Hi, `evalJS` tells Prototype not to evaluate JSON, not scripts.[1] Ajax.Request doesn't evaluate script tags at all. Ajax.Updater will, unless you pass it the `evalScripts: false` option.[2] If you're using Ajax.Request, the only way I'm seeing script tags get processed is if you then use that content with Element#update.[3] Element#update will process all of the tags you feed to it, including script tags. You can strip them out of your response before feeding them to Element#update by using String#stripScripts.[4] [1] http://api.prototypejs.org/ajax/ [2] http://api.prototypejs.org/ajax/ajax/updater/ [3] http://api.prototypejs.org/dom/element/update/ [4] http://api.prototypejs.org/language/string/prototype/stripscripts/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On May 18, 5:35 am, orbiter dkarapet...@gmail.com wrote: I've a little web app that loads and unloads pages with script tags in them and even though I pass evalJS: false to the Ajax.Request I still get an error message that says pq is not definedhttp://localhost/test/javascript/prototype.js Line 605 return this.extractScripts()... How can I prevent prototype from evaluating the script tags in the incoming response? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request and evalJS bug
You are right. I am using Element#update and that's exactly when the eval script is getting called. I did a little debugging in firebug that I should have done sooner but thank you for the info. On May 17, 11:02 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, `evalJS` tells Prototype not to evaluate JSON, not scripts.[1] Ajax.Request doesn't evaluate script tags at all. Ajax.Updater will, unless you pass it the `evalScripts: false` option.[2] If you're using Ajax.Request, the only way I'm seeing script tags get processed is if you then use that content with Element#update.[3] Element#update will process all of the tags you feed to it, including script tags. You can strip them out of your response before feeding them to Element#update by using String#stripScripts.[4] [1]http://api.prototypejs.org/ajax/ [2]http://api.prototypejs.org/ajax/ajax/updater/ [3]http://api.prototypejs.org/dom/element/update/ [4]http://api.prototypejs.org/language/string/prototype/stripscripts/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On May 18, 5:35 am, orbiter dkarapet...@gmail.com wrote: I've a little web app that loads and unloads pages with script tags in them and even though I pass evalJS: false to the Ajax.Request I still get an error message that says pq is not definedhttp://localhost/test/javascript/prototype.js Line 605 return this.extractScripts()... How can I prevent prototype from evaluating the script tags in the incoming response? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request and evalJS bug
No worries! Glad that helped. -- T.J. On May 18, 8:59 am, orbiter dkarapet...@gmail.com wrote: You are right. I am using Element#update and that's exactly when the eval script is getting called. I did a little debugging in firebug that I should have done sooner but thank you for the info. On May 17, 11:02 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, `evalJS` tells Prototype not to evaluate JSON, not scripts.[1] Ajax.Request doesn't evaluate script tags at all. Ajax.Updater will, unless you pass it the `evalScripts: false` option.[2] If you're using Ajax.Request, the only way I'm seeing script tags get processed is if you then use that content with Element#update.[3] Element#update will process all of the tags you feed to it, including script tags. You can strip them out of your response before feeding them to Element#update by using String#stripScripts.[4] [1]http://api.prototypejs.org/ajax/ [2]http://api.prototypejs.org/ajax/ajax/updater/ [3]http://api.prototypejs.org/dom/element/update/ [4]http://api.prototypejs.org/language/string/prototype/stripscripts/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On May 18, 5:35 am, orbiter dkarapet...@gmail.com wrote: I've a little web app that loads and unloads pages with script tags in them and even though I pass evalJS: false to the Ajax.Request I still get an error message that says pq is not definedhttp://localhost/test/javascript/prototype.js Line 605 return this.extractScripts()... How can I prevent prototype from evaluating the script tags in the incoming response? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request and evalJS bug
`evalJS` tells Prototype not to evaluate JSON, not scripts. That's actually incorrect. - `evalJSON` controls the evaluation of JSON data, - `evalJS` of JavaScript programs served through xhr, and - `evalScripts` of the content of script tags found in the responseText property of the xhr object. Best, Tobie -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request and evalJS bug
Hi Tobie, That's actually incorrect. Thanks! It struck me as odd but I figured I was just misremembering, because I was drawing on the docs for that answer -- and they say[1] `evalJS` controls JSON eval: evalJS (Boolean | String; default true): Automatically evals the content of Ajax.Response#responseText and populates Ajax.Response#responseJSON with it if the Content-type returned by the server is set to application/json. If the request doesn't obey same- origin policy, the content is sanitized before evaluation. If you need to force evalutation, pass 'force'. To prevent it altogether, pass false. That looks like it's kind of a mashed-together version of the two of them. I've double-checked the source, and it seems at a glance that (unsurprisingly!) you're right, so I've filed a ticket[2] in Lighthouse about it. [1] http://api.prototypejs.org/ajax/ [2] https://prototype.lighthouseapp.com/projects/42103-prototype-documentation/tickets/162 -- T.J. On May 18, 1:44 pm, Tobie Langel tobie.lan...@gmail.com wrote: `evalJS` tells Prototype not to evaluate JSON, not scripts. That's actually incorrect. - `evalJSON` controls the evaluation of JSON data, - `evalJS` of JavaScript programs served through xhr, and - `evalScripts` of the content of script tags found in the responseText property of the xhr object. Best, Tobie -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request works - form.request() does not - on IE 8.0
Hey, Can you put your code in order to have a better view of your problem? This kind of request works on IE so it should be a little mistake in your code. Just put it there and we will try to help you :) Bye, Jinsa. On May 5, 9:27 am, walther diechmann waltherdiechm...@gmail.com wrote: Anyone got a take on this issue? I have a form which gets loaded dynamically and is POST'ed behind the curtains using a form.request() on the submit button (in an attempt to degrade nicely) - this works in FF, Opera, Chrome and Safari (on Mac and PC) - but IE? Noo... On IE the request is received server-side - but with no parameters to show for its name :) (tried a Ajax.Request with Form.serialize() and that is OK) Cheers, Walther -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request works - form.request() does not - on IE 8.0
Hey Jinsa, good of you! Hard pressed to come up with a solution, I ran the HTML (generated by Formtastic) through validator.w3.org - and turned out the input tag was not closed properly ( input / was missing the slash). Posted my observation to the Formtastic group here on Google - and they pointed my attention to the DOCTYPE. I use the DOCTYPE suggested by the Rails framework - but browsers apparently do not interpret the handling of tags uniformly :( (really can't say I didn't know that) Lesson learned: building documents dynamically using innerHTML - or via Prototype methods (replace and update) - it is of vital importance to have the dynamic HTML validated, or selecting a DOCTYPE which will allow for looser interpretations, at least pertaining to forms manipulation and Ajax calls. I have to apologise here! Neither Prototype nor Script.aculo.us is to blame - and I've been crying wolf for no reason at all. Please excuse my lack of command in the W3C specs :( Cheers, Walther On 6 Maj, 10:32, Jinsa jf.wesq...@gmail.com wrote: Hey, Can you put your code in order to have a better view of your problem? This kind of request works on IE so it should be a little mistake in your code. Just put it there and we will try to help you :) Bye, Jinsa. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request - onComplete(response, possible second arg?)
Hi, There have been some interesting issues, and mostly I've fixed (with no help from the deprecation script, as it doesn't work). Have you filed bug report(s) for the way/ways in which you don't think it works? (Although at this point, as it's been two and a half years since 1.6.0 was released, I'm not sure the core devs would action them.) So, one issue I've come accross, I need to know if passing a second parameter to the onComplete Ajax.Request is still possible. The onComplete callback still receives a second argument: ...all callbacks (except onException) are invoked with two parameters: the Ajax.Response object and the result of evaluating the X-JSON response header, if any (can be null).[1] So as long as your PHP code is sending the result from json_encode as a response header with the name X-JSON, it should be showing up in your onComplete handler. [1] http://api.prototypejs.org/ajax/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 30, 10:02 pm, Yaz yasm...@gmail.com wrote: Hi all, I've have been working with a *lot* of javascript code, all done in prototype 1.5. The company I work for, has decided to upgrade prototype libraries. So I have upgraded prototype and scriptaculous, and about 5 others. There have been some interesting issues, and mostly I've fixed (with no help from the deprecation script, as it doesn't work). So, one issue I've come accross, I need to know if passing a second parameter to the onComplete Ajax.Request is still possible. There are a ton of Ajax.Request calls like this: new Ajax.Request('some_url.php', { parameters : Parameters, evalScripts : true, onComplete: function(response, arrSomeStuff){ // from php arrSomeStuff is passed like this json_encode(arrSomeStuff); $('some_div').update(arrSomeStuff.value_name); }, onFailure: function(response){ // handle errors } }); Now, I don't know why the arrSomeStuff was passed along as a second argument, as response has the same information. But, the advantage, was that in 1.5, that array came perfectly, you didn't have to get it out of the response var. But, it doesn't work on 1.6. And there is too much code for me to try to adapt this (30 files, each using it about 20 times). So far, everything works, except it doesn't execute the update because arrSomeStuff.value_name is null. Any ideas?? Thanks!! :) -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: AJAX.Request complains about 'function expected' in IE6
I think: requestHeaders: ['Accept-Encoding', ''] should be: requestHeaders: {'Accept-Encoding': ''} 'msg' is not explicitly defined in your post, it is set somewhere, right? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: AJAX.Request complains about 'function expected' in IE6
Yes, it was populated above with some complex JSON string. Thanks! On Thu, Mar 18, 2010 at 9:16 AM, disccomp discc...@gmail.com wrote: I think: requestHeaders: ['Accept-Encoding', ''] should be: requestHeaders: {'Accept-Encoding': ''} 'msg' is not explicitly defined in your post, it is set somewhere, right? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- Shane McCarron halindr...@gmail.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: AJAX.Request complains about 'function expected' in IE6
Hi, I think: requestHeaders: ['Accept-Encoding', ''] should be: requestHeaders: {'Accept-Encoding': ''} Believe it or not, the docs say it works either way: http://prototypejs.org/api/ajax/options But if Shane's was more complex, then that might be the issue. -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Mar 18, 6:05 pm, Shane McCarron halindr...@gmail.com wrote: Yes, it was populated above with some complex JSON string. Thanks! On Thu, Mar 18, 2010 at 9:16 AM, disccomp discc...@gmail.com wrote: I think: requestHeaders: ['Accept-Encoding', ''] should be: requestHeaders: {'Accept-Encoding': ''} 'msg' is not explicitly defined in your post, it is set somewhere, right? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculou s%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- Shane McCarron halindr...@gmail.com -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Hi again, I _thought_ it was as easy (in this case) as setting the Access-Control- Allow-Origin header to * in response to the OPTIONS request, but apparently there's more to it as that didn't work in my five-minute test, which is all I have time for this morning. Well, I got to thinking that I really needed to know more about CORS, so I read key parts of the spec and realized I was being a *bit* too simplistic, but wasn't a million miles off. Adding the following to both the OPTIONS response and to the actual request response (the GET or POST) allows any origin to query my JSP with a CORS-enabled browser and so makes things work for me in Firefox and Chrome in your local-file-requesting-web-resource scenario (as well as my port 8080 = port 8701 scenario): response.addHeader(Access-Control-Allow-Origin, *); response.addHeader(Access-Control-Allow-Methods, request.getHeader(Access-Control-Request-Methods)); response.addHeader(Access-Control-Allow-Headers, request.getHeader(Access-Control-Request-Headers)); What that's doing (line by line) is: 1. Allowing *any* origin to do the request (Access-Control-Allow- Origin: *). This is probably a bad idea unless you really do want to make the resource globally accessible (but then, there are lots of valid use cases for that). To lock it down a bit more, your best bet is to examine the Origin request header (request.getHeader(Origin)) and determine whether you want to allow access from that origin and if so echo that value back for your Access- Control-Allow-Origin response header. The Origin I get when requesting from a file:// resource is null, which is intresting, so in your scenario you'd probably have to use *. 2. Allowing the request to use the methods (and only the methods) it's asked to use. Alternately you could just say GET, POST if you wanted to allow GET and POST, but it seems a bit silly to allow more than they've asked for. You might, of course, allow *less* than they've asked for, in which case (in theory) they might adjust what they're doing. 3. Allow the request to use the headers it's asked to use. Once again, you may wish to limit what headers they can use, but this was the key bit I was missing previously. Caveat user: I'm learning this stuff, I can't say that the discussion above is thorough (read the W3 doc) or informed (it isn't). But it's plenty to allow you to do something internal like your example. I would just read up a lot more before doing anything publicly- accessible. Happy coding, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Mar 16, 8:49 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, T.J, thanks for your reply as well. The answer to your first question (the URL of the page that this is part of) is that I'm just having an HTML file sitting on my desktop. AH. That's a very significant piece of information there. :-) Without it, we're all assuming you're serving the original page from a web server. I've replicated the results you're getting. My suspicion is that if you modify your servlet to handle the OPTIONS method (doOptions[1]), you'll find that both Firefox and Chrome are sending an OPTIONS command to the servlet asking it whether it's accessible to the file:// origin you're requesting from. This is part of CORS[2][3], the new cross-origin resource sharing stuff. IE apparently doesn't think that it's a cross-origin request and so it's simply doing the request, not applying the SOP[4]. I haven't gotten into CORS much yet. The basic thing is that the browser asks the target resource (via the OPTIONS method) whether it's okay for the origin to access that resource. If the origin replies with response headers allowing the original request, the browser performs the original request (GET, POST, whatever). If not, it disallows the request, which is what you're seeing. If you search for CORS examples on the web, I expect you'll find at least one in Java. I _thought_ it was as easy (in this case) as setting the Access-Control- Allow-Origin header to * in response to the OPTIONS request, but apparently there's more to it as that didn't work in my five-minute test, which is all I have time for this morning. Good luck with it! [1]http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServlet) [2]http://www.w3.org/TR/cors/ [3]https://developer.mozilla.org/En/HTTP_access_control [4]http://en.wikipedia.org/wiki/Same_origin_policy -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Mar 15, 2:10 pm, Ronen rrotst...@gmail.com wrote: Thanks for correcting me on ActiveX... I didn't know that internally, an XMLHttpRequest object gets used in the end. In response to disccomp, I'm not sure how I would use a relative URL. Could you give an example? I've tried using a value such as /MyApp/ MyServlet, but this doens't work at all (even in IE), which I can
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Excellent. Thanks very much T.J.. your idea worked. In my servlet, I overrided the doOptions() method from HttpServlet and returned the response headers that you suggested: response.addHeader(Access-Control-Allow-Origin, *); response.addHeader(Access-Control-Allow-Methods, request.getHeader(Access-Control-Request-Methods)); response.addHeader(Access-Control-Allow-Headers, request.getHeader(Access-Control-Request-Headers)); and Firefox and Chrome both started working beautifully (also verified that IE still works). In the end, my overall intent is to package this HTML file with my web application, so it sounds like I won't need to have this doOptions() in my servlet. It's just that in the beginning, I figured I would test the HTML file outside of the web app and I guess I didn't realize I would run into this kind of trouble. Still, it's always good to know how to go about fixing something like this in the future. Thanks for everyone's help. --Ronen On Mar 16, 5:52 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi again, I _thought_ it was as easy (in this case) as setting the Access-Control- Allow-Origin header to * in response to the OPTIONS request, but apparently there's more to it as that didn't work in my five-minute test, which is all I have time for this morning. Well, I got to thinking that I really needed to know more about CORS, so I read key parts of the spec and realized I was being a *bit* too simplistic, but wasn't a million miles off. Adding the following to both the OPTIONS response and to the actual request response (the GET or POST) allows any origin to query my JSP with a CORS-enabled browser and so makes things work for me in Firefox and Chrome in your local-file-requesting-web-resource scenario (as well as my port 8080 = port 8701 scenario): response.addHeader(Access-Control-Allow-Origin, *); response.addHeader(Access-Control-Allow-Methods, request.getHeader(Access-Control-Request-Methods)); response.addHeader(Access-Control-Allow-Headers, request.getHeader(Access-Control-Request-Headers)); What that's doing (line by line) is: 1. Allowing *any* origin to do the request (Access-Control-Allow- Origin: *). This is probably a bad idea unless you really do want to make the resource globally accessible (but then, there are lots of valid use cases for that). To lock it down a bit more, your best bet is to examine the Origin request header (request.getHeader(Origin)) and determine whether you want to allow access from that origin and if so echo that value back for your Access- Control-Allow-Origin response header. The Origin I get when requesting from a file:// resource is null, which is intresting, so in your scenario you'd probably have to use *. 2. Allowing the request to use the methods (and only the methods) it's asked to use. Alternately you could just say GET, POST if you wanted to allow GET and POST, but it seems a bit silly to allow more than they've asked for. You might, of course, allow *less* than they've asked for, in which case (in theory) they might adjust what they're doing. 3. Allow the request to use the headers it's asked to use. Once again, you may wish to limit what headers they can use, but this was the key bit I was missing previously. Caveat user: I'm learning this stuff, I can't say that the discussion above is thorough (read the W3 doc) or informed (it isn't). But it's plenty to allow you to do something internal like your example. I would just read up a lot more before doing anything publicly- accessible. Happy coding, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Mar 16, 8:49 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, T.J, thanks for your reply as well. The answer to your first question (the URL of the page that this is part of) is that I'm just having an HTML file sitting on my desktop. AH. That's a very significant piece of information there. :-) Without it, we're all assuming you're serving the original page from a web server. I've replicated the results you're getting. My suspicion is that if you modify your servlet to handle the OPTIONS method (doOptions[1]), you'll find that both Firefox and Chrome are sending an OPTIONS command to the servlet asking it whether it's accessible to the file:// origin you're requesting from. This is part of CORS[2][3], the new cross-origin resource sharing stuff. IE apparently doesn't think that it's a cross-origin request and so it's simply doing the request, not applying the SOP[4]. I haven't gotten into CORS much yet. The basic thing is that the browser asks the target resource (via the OPTIONS method) whether it's okay for the origin to access that resource. If the origin replies with response headers allowing the original request, the browser performs the original request (GET, POST, whatever). If not, it disallows the
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Hi, From IE, it works just fine (probably because it's using ActiveX rather than XMLHttpRequest) Not *rather than* -- it's using XMLHttpRequest regardless. On older versions of IE, the way you get one is via ActiveX, but that's irrelevant (and only older versions); it's an XMLHttpRequest regardless. var asyncReq = new Ajax.Request(http://localhost:8701/MyApp/ MyServlet, opts); What's the URL of the page this is a part of? Because the fact you've given a full URL there makes me think this is not relative to the page, which makes me wonder if you're running afoul of the Same Origin Policy[1] (because remember, different ports are different origins). But in that case, I wouldn't expect IE to work, either, not even IE6. When I try this in my setup, requesting from localhost:8080 to localhost:8701, using IE7 I simply get an access denied error and my servlet (okay, it's a JSP for test purposes) is never triggered at all. When I try this from Firefox or Chrome, because they support CORS[2][3], I see the OPTIONS request to my JSP seeking permission for cross-origin requests. [1] http://en.wikipedia.org/wiki/Same_origin_policy [2] http://www.w3.org/TR/cors/ [3] https://developer.mozilla.org/En/HTTP_access_control FWIW, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Mar 12, 2:53 pm, Ronen rrotst...@gmail.com wrote: I've downloaded the latest prototype (version 1.6.1) and tried to call a java servlet using Ajax.Request. From IE, it works just fine (probably because it's using ActiveX rather than XMLHttpRequest), but I'm having no luck with Firefox (v3.6) and Chrome (4.0). The servlet that I'm calling performs a log operation right away so I can see whether it was called or not. That's how I know that IE is successful but firefox and chrome aren't. I've used Firebug to try to debug firefox and I see that the line this.transport.send(this.body); is, in fact, being called by firefox. But still, my servlet shows no log of being called. The exact javascript I'm using is below: var opts = { method: 'post', parameters : { key:value }, onSuccess: function(transport) { var d = new Date(); document.getElementById(location).value = d.getTime(); } } var asyncReq = new Ajax.Request(http://localhost:8701/MyApp/ MyServlet, opts); As you can see, in the success method, I just populate a textbox to have the current date/time, and this actually works in all browsers (IE, Firefox, Chrome). Just that in Firefox and Chrome the servlet is not physically being called (yet the success method is). Any help in solving this issue is greatly appreciated. --Ronen -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Thanks for correcting me on ActiveX... I didn't know that internally, an XMLHttpRequest object gets used in the end. In response to disccomp, I'm not sure how I would use a relative URL. Could you give an example? I've tried using a value such as /MyApp/ MyServlet, but this doens't work at all (even in IE), which I can understand since this is not specifying exactly how to reach the servlet. T.J, thanks for your reply as well. The answer to your first question (the URL of the page that this is part of) is that I'm just having an HTML file sitting on my desktop. This is the HTML file that I'm loading up in IE, Firefox, and Chrome. So it's not part of any web app, but rather just tries to invoke a servlet on a web app that is currently deployed. Would this make a difference? (If so, how can we explain why it works on IE?) In any case, I can and will try to load an HTML file that is part of the same web app (since that's the overall intent anyways), but I guess I'm not very confident in this fixing the issue. Also, the reason I use 8701 is because I'm trying this at work where I'm using WebLogic (and the port is set up as 8701), but on my home machine, I am using tomcat so I use 8080 like you did. On Mar 15, 4:25 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, From IE, it works just fine (probably because it's using ActiveX rather than XMLHttpRequest) Not *rather than* -- it's using XMLHttpRequest regardless. On older versions of IE, the way you get one is via ActiveX, but that's irrelevant (and only older versions); it's an XMLHttpRequest regardless. var asyncReq = new Ajax.Request(http://localhost:8701/MyApp/ MyServlet, opts); What's the URL of the page this is a part of? Because the fact you've given a full URL there makes me think this is not relative to the page, which makes me wonder if you're running afoul of the Same Origin Policy[1] (because remember, different ports are different origins). But in that case, I wouldn't expect IE to work, either, not even IE6. When I try this in my setup, requesting from localhost:8080 to localhost:8701, using IE7 I simply get an access denied error and my servlet (okay, it's a JSP for test purposes) is never triggered at all. When I try this from Firefox or Chrome, because they support CORS[2][3], I see the OPTIONS request to my JSP seeking permission for cross-origin requests. [1]http://en.wikipedia.org/wiki/Same_origin_policy [2]http://www.w3.org/TR/cors/ [3]https://developer.mozilla.org/En/HTTP_access_control FWIW, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Mar 12, 2:53 pm, Ronen rrotst...@gmail.com wrote: I've downloaded the latest prototype (version 1.6.1) and tried to call a java servlet using Ajax.Request. From IE, it works just fine (probably because it's using ActiveX rather than XMLHttpRequest), but I'm having no luck with Firefox (v3.6) and Chrome (4.0). The servlet that I'm calling performs a log operation right away so I can see whether it was called or not. That's how I know that IE is successful but firefox and chrome aren't. I've used Firebug to try to debug firefox and I see that the line this.transport.send(this.body); is, in fact, being called by firefox. But still, my servlet shows no log of being called. The exact javascript I'm using is below: var opts = { method: 'post', parameters : { key:value }, onSuccess: function(transport) { var d = new Date(); document.getElementById(location).value = d.getTime(); } } var asyncReq = new Ajax.Request(http://localhost:8701/MyApp/ MyServlet, opts); As you can see, in the success method, I just populate a textbox to have the current date/time, and this actually works in all browsers (IE, Firefox, Chrome). Just that in Firefox and Chrome the servlet is not physically being called (yet the success method is). Any help in solving this issue is greatly appreciated. --Ronen -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
I have had similar issues before in my applications. I have always assumes that they were caching issues. With the method as 'post' and adding the current date and time in the parameters field (or query string), I've been able to get past this issue. This is to make sure the url being called is alway unique. You may want to parse out punctuation characters though. I would be interested to know if this is some sort of application scope issue like T.J. Crowder is suggesting. It seems unlikely due to the fact that IE is allowing it. Although I have seen IE do some pretty weird stuff I wouldn't ignore the possibility. On Mar 12, 6:53 am, Ronen rrotst...@gmail.com wrote: I've downloaded the latest prototype (version 1.6.1) and tried to call a java servlet using Ajax.Request. From IE, it works just fine (probably because it's using ActiveX rather than XMLHttpRequest), but I'm having no luck with Firefox (v3.6) and Chrome (4.0). The servlet that I'm calling performs a log operation right away so I can see whether it was called or not. That's how I know that IE is successful but firefox and chrome aren't. I've used Firebug to try to debug firefox and I see that the line this.transport.send(this.body); is, in fact, being called by firefox. But still, my servlet shows no log of being called. The exact javascript I'm using is below: var opts = { method: 'post', parameters : { key:value }, onSuccess: function(transport) { var d = new Date(); document.getElementById(location).value = d.getTime(); } } var asyncReq = new Ajax.Request(http://localhost:8701/MyApp/ MyServlet, opts); As you can see, in the success method, I just populate a textbox to have the current date/time, and this actually works in all browsers (IE, Firefox, Chrome). Just that in Firefox and Chrome the servlet is not physically being called (yet the success method is). Any help in solving this issue is greatly appreciated. --Ronen -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Thanks for the suggestion Scott. I've tried to add the current timestamp (via the javascript expression new Date().getTime() ) to the parameters and the query string (in all the combinations such as first adding it only to parameters, then only to query string, and then to both) and unfortunately, still no luck. I did verify that in IE, the timestamp was being received by the servlet. One thing I did catch, however, is that the first time I tried it in firefox, firebug reported this exception: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send This was thrown by the line this.transport.send() of prototype.js, but subsequent times, firefox did not produce this exception anymore (the ajax request did not raise any exceptions, yet still no luck in reaching the servlet) I looked this error code up on google and also tried looking it up on Mozilla's Source Code site (http://mxr.mozilla.org/mozilla1.8.0/source/ extensions/xmlextras/base/src/nsXMLHttpRequest.cpp#1423) and it looks like this NS_ERROR_FAILURE error is returned by the send() method in three places: Line 1429 (this is the case where more than one request is made with the same XMLHttpRequest object) Line 1553 (not quite sure how this one works) Line 1626 (right before firefox returns a successful response, it check whether mChannel exists, and if not, it returns this error).. my guess would be that this is the line that's causing my request not to work, but I can't figure out why. --Ronen On Mar 15, 10:15 am, Scott counterstre...@gmail.com wrote: I have had similar issues before in my applications. I have always assumes that they were caching issues. With the method as 'post' and adding the current date and time in the parameters field (or query string), I've been able to get past this issue. This is to make sure the url being called is alway unique. You may want to parse out punctuation characters though. I would be interested to know if this is some sort of application scope issue like T.J. Crowder is suggesting. It seems unlikely due to the fact that IE is allowing it. Although I have seen IE do some pretty weird stuff I wouldn't ignore the possibility. On Mar 12, 6:53 am, Ronen rrotst...@gmail.com wrote: I've downloaded the latest prototype (version 1.6.1) and tried to call a java servlet using Ajax.Request. From IE, it works just fine (probably because it's using ActiveX rather than XMLHttpRequest), but I'm having no luck with Firefox (v3.6) and Chrome (4.0). The servlet that I'm calling performs a log operation right away so I can see whether it was called or not. That's how I know that IE is successful but firefox and chrome aren't. I've used Firebug to try to debug firefox and I see that the line this.transport.send(this.body); is, in fact, being called by firefox. But still, my servlet shows no log of being called. The exact javascript I'm using is below: var opts = { method: 'post', parameters : { key:value }, onSuccess: function(transport) { var d = new Date(); document.getElementById(location).value = d.getTime(); } } var asyncReq = new Ajax.Request(http://localhost:8701/MyApp/ MyServlet, opts); As you can see, in the success method, I just populate a textbox to have the current date/time, and this actually works in all browsers (IE, Firefox, Chrome). Just that in Firefox and Chrome the servlet is not physically being called (yet the success method is). Any help in solving this issue is greatly appreciated. --Ronen -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Are you sure your servlet is responding with the proper headers. Try creating a small self-contained minimum test case which fails. Using a relative URL ensures that it is from the same origin as the loading page. -Mark -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request - can't get to work in Firefox, Chrome
Thanks for the quick reply.. yes, I have tried clearing the cache in both firefox and chrome, but still no luck. --Ronen On Mar 13, 4:14 am, Guillaume Lepicard guillaume.lepic...@gmail.com wrote: hi ronen, could it be a browser cache issue ? have you tried clearing cache before running ajax ? On Fri, Mar 12, 2010 at 3:53 PM, Ronen rrotst...@gmail.com wrote: I've downloaded the latest prototype (version 1.6.1) and tried to call a java servlet using Ajax.Request. From IE, it works just fine (probably because it's using ActiveX rather than XMLHttpRequest), but I'm having no luck with Firefox (v3.6) and Chrome (4.0). The servlet that I'm calling performs a log operation right away so I can see whether it was called or not. That's how I know that IE is successful but firefox and chrome aren't. I've used Firebug to try to debug firefox and I see that the line this.transport.send(this.body); is, in fact, being called by firefox. But still, my servlet shows no log of being called. The exact javascript I'm using is below: var opts = { method: 'post', parameters : { key:value }, onSuccess: function(transport) { var d = new Date(); document.getElementById(location).value = d.getTime(); } } var asyncReq = new Ajax.Request(http://localhost:8701/MyApp/ MyServlet, opts); As you can see, in the success method, I just populate a textbox to have the current date/time, and this actually works in all browsers (IE, Firefox, Chrome). Just that in Firefox and Chrome the servlet is not physically being called (yet the success method is). Any help in solving this issue is greatly appreciated. --Ronen -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request
I wrestled with asynchronous calls like you have (and quite honestly, found the structure associated with the onSuccess/onFailure lead to confusing code) I eventually settled on using var myAjax = new Ajax.Updater( target, url, {method: 'post', parameters: pars, evalScripts: true} ); (AFAIK, 'evalScripts: true' does not seem to work with Ajax.Request... someone please corrected me if I'm wrong) I then code within the url to generate the scripts that should be spawned on success or failure (and I can set things so that the scripts don't get called until all of the prerequisite bits are available). Depending on the nature of the calls/results, I occasionally set the target to a hidden div. Once I settled on this approach, I had carefully (re-)structure my code so that calls cascaded properly... i.e., I found that on occasion, the same functions were getting spawned from differenturl's (meaning that the pages could regenerating things unnecessarily). Hope this helps, Al On Dec 20, 6:35 am, kangur91 kangu...@gmail.com wrote: My code: function get_data_default() { new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ return data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } });} } function show(){alert(get_data_default());} I want to function get_data_default return data recived from OnSucces function. How do that? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Ajax.Request
If i recall correctly ... Failure only gets called on a server error ... like a 404 ... The failure may be due to a javascript error and would not return the alert if that was the case. On the back success only calls when the server has responded... Ergo there are many things that can go wrong - i've listed a couple below 1. Transit. To/From the server 2. Server side scripts (will return whitespace upon an error - if error reporting is turned off) and this is still considered a success by javascript. Also i noticed in the original post that you had asynchronous: true... It is true by default so you can save a few bites there. As TJ said in an earlier reply, You cannot return out of the Ajax request as it is run asyncronously with the page (meaning [in easy terms] you can execute alot of javascript at the same time as the request without locking the browser]). To perform what you want to achieve (if i'm getting what you want to do correctly) you should create a response handler ... something akin to onSuccess : function(data) { myHandler({data:data.responseText.evalJSON,vars:someotherVars}); } ... function myHandler(options) { var ReposnseData=options.data; $('someElement').update(ResponseData); } Hope this helps... Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Al C al.caug...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, December 22, 2009 2:29 PM Subject: [Proto-Scripty] Re: Ajax.Request I wrestled with asynchronous calls like you have (and quite honestly, found the structure associated with the onSuccess/onFailure lead to confusing code) I eventually settled on using var myAjax = new Ajax.Updater( target, url, {method: 'post', parameters: pars, evalScripts: true} ); (AFAIK, 'evalScripts: true' does not seem to work with Ajax.Request... someone please corrected me if I'm wrong) I then code within the url to generate the scripts that should be spawned on success or failure (and I can set things so that the scripts don't get called until all of the prerequisite bits are available). Depending on the nature of the calls/results, I occasionally set the target to a hidden div. Once I settled on this approach, I had carefully (re-)structure my code so that calls cascaded properly... i.e., I found that on occasion, the same functions were getting spawned from differenturl's (meaning that the pages could regenerating things unnecessarily). Hope this helps, Al On Dec 20, 6:35 am, kangur91 kangu...@gmail.com wrote: My code: function get_data_default() { new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ return data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } });} } function show(){alert(get_data_default());} I want to function get_data_default return data recived from OnSucces function. How do that? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Re: Ajax.Request
An alternative i sometimes use is to set a timeout on a function to check within a period of time - usually a hidden input with the time of the request - checking it until its complete That way i can know if anyting failed in the request and send it again if it did ... each to their own ! Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Walter Lee Davis wa...@wdstudio.com To: prototype-scriptaculous@googlegroups.com Sent: Tuesday, December 22, 2009 3:54 PM Subject: Re: [Proto-Scripty] Re: Ajax.Request This is an important thing to work on. If I know I will be using onError on the client side, I make sure that my Ajax endpoint on the server will return a real error header using PHP's header() method. You can also get very fancy with different error header codes, too, throwing a distinctly different error depending on the nature of that error, and then handling it in the Ajax callback using one of the onNNN methods instead of onError (which covers any error between 400 and 5NN, IIRC). Walter On Dec 22, 2009, at 10:21 AM, Alex McAuley wrote: 2. Server side scripts (will return whitespace upon an error - if error reporting is turned off) and this is still considered a success by javascript. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request
function show(){alert(get_data_default());} This line will fail when you call show() because you're not passing a function to fill the callback variable inside get_data_default(). Also, method:post and asynchronous:true are the defaults for those options. You don't need to specify them if you plan to keep those settings. -joe t. On Dec 20, 10:47 pm, heeae csche...@gmail.com wrote: I will using this approach function get_data_default(callback){ new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ callback(data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } }); } function show(){alert(get_data_default());} var data = null; function processData(obj){ data = obj; alert(data.abc); } if(data == null){ get_data_default(processData); }else{ alert(data.abc); } On Dec 20, 7:35 pm, kangur91 kangu...@gmail.com wrote: My code: function get_data_default() { new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ return data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } });} } function show(){alert(get_data_default());} I want to function get_data_default return data recived from OnSucces function. How do that? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request
sorry for typing mistake, I am intended to represent the concept of using callback. and I think keeping default variable is not bad as we cant tell the default value not to be changed in the next generation of prototype js. heeae On Dec 22, 1:25 pm, joe t. thooke...@gmail.com wrote: function show(){alert(get_data_default());} This line will fail when you call show() because you're not passing a function to fill the callback variable inside get_data_default(). Also, method:post and asynchronous:true are the defaults for those options. You don't need to specify them if you plan to keep those settings. -joe t. On Dec 20, 10:47 pm, heeae csche...@gmail.com wrote: I will using this approach function get_data_default(callback){ new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ callback(data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } }); } function show(){alert(get_data_default());} var data = null; function processData(obj){ data = obj; alert(data.abc); } if(data == null){ get_data_default(processData); }else{ alert(data.abc); } On Dec 20, 7:35 pm, kangur91 kangu...@gmail.com wrote: My code: function get_data_default() { new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ return data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } });} } function show(){alert(get_data_default());} I want to function get_data_default return data recived from OnSucces function. How do that? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request
Hi, I want to function get_data_default return data recived from OnSucces function. How do that? The best way is by changing your approach so that you can request the data, and then process it later when it comes back. If you're using an asynchronous request, there is no way for the function initiating the request to return the result -- the result isn't available when the function returns. You *could* use a synchronous request instead, but that's a very bad idea -- it makes your page (at least) or the entire browser (at worst) completely unresponsive until the request completes, depending on what browser the user is using. Some browsers don't even *repaint* while the request is outstanding. (BTW: You can't return any information from the onSuccess handler; that handler is called by Prototype, which ignores any return value from it.) HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Dec 20, 11:35 am, kangur91 kangu...@gmail.com wrote: My code: function get_data_default() { new Ajax.Request('/adress', { method:'post', asynchronous:true, onSuccess: function(data){ return data.responseText.evalJSON (true); }, onFailure: function(){ alert('Something went wrong...') } });} } function show(){alert(get_data_default());} I want to function get_data_default return data recived from OnSucces function. How do that? -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
[Proto-Scripty] Re: Ajax.Request not sending request to server in IE8, but processing continues with stale/cached response
IE and a couple of other browsers cache get requests... If you want to fix it either use TJ's suggestion or use post and not get Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Brad Whitaker To: prototype-scriptaculous@googlegroups.com Sent: Friday, November 06, 2009 11:02 PM Subject: [Proto-Scripty] Re: Ajax.Request not sending request to server in IE8, but processing continues with stale/cached response T.J., Thank you very much for the response. The problem is reproducible in my development environment where I verified using Firebug that no Expires header is set on the Ajax response. I tried your last resort suggestion and the problem goes away. (I know it is a hack but I'm going to deploy it because I need a quick fix). I'll see if I can produce and submit a minimalist example that reproduces the problem. Thanks, Brad T.J. Crowder wrote: Hi Brad, Can you produce a minimalist, self-contained example[1] demonstrating the problem? It sounds a bit like an IE8 issue, as I thought all XHR requests were supposed to bypass local cache, but perhaps I'm wrong about that. Are you sure you're setting the cachability of the result correctly? E.g., that it should not be cached? (This would be in the headers of the result.) You might want to check your cache-control headers. In the worst case (and this really should be a last resort), you should be able to defeat caching by adding a query parameter that's constantly changing, e.g.: new Ajax.Request(url + ?foo= + (new Date().getTime()), ...); [1] http://proto-scripty.wikidot.com/self-contained-test-page HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Nov 3, 8:46 pm, Brad Whitaker b...@agilemark.com wrote: I'm having a problem with Ajax.Request in IE8 that I can't understand. My code is working fine in other browsers. If I use the IE8 menu to clear the browser cache to my domain then my next Ajax.Request() works properly. But when Ajax.Request is invoked again this problem arises: 1) no request is actually sent to my server; 2) processing continues normally but the content I see is from the previous request (in other words, it is old content). Any suggestions about how I might resolve this issue would be greatly appreciated. onSuccess and onComplete are both being invoked even when the server request is not issued. (In case additional details are helpful: I'm invoking Ajax.Request() from within Prototype-UI window.js setAjaxContent() function, and the content is used to fully populate a modal window). Thanks, Brad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
JSON response ... {success : true, message : good} Code ... function ajaxRequest2(){ var url = /cgidev2p/r_chgpwd.pgm; var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F('v_confirm')) + 'sessionid=' + escape($F('sessionid')); //var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', //contentType: 'application/json', parameters: pars, onSuccess: function(transport){ alert(Success); var json = transport.responseJSON; alert(json.success); } , onError: function(transport){ alert(skipped); } , onComplete: function(transport){ alert(Complete); } }); } Alerts that I see are Success and Complete. The alert(json.success) does not fire. If I change the code to alert(json) the alert fires with null. -Original Message- From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Alex McAuley Sent: Saturday, October 31, 2009 5:20 AM To: prototype-scriptaculous@googlegroups.com Subject: [Proto-Scripty] Re: Ajax.Request with JSON response If its Json then the alert would be... alert(jsonObj.success); HTH Alex Mcauley http://www.thevacancymarket.com - Original Message - From: mjhaston mjhas...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, October 30, 2009 1:21 PM Subject: [Proto-Scripty] Re: Ajax.Request with JSON response The success alert fires off, but not the feeling ok alert. function ajaxRequest2(){ var url = /cgidev2p/r_chgpwd.pgm; var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F ('v_confirm')) + 'sessionid=' + escape($F('sessionid')); //var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', contentType: 'application/json', parameters: pars, onSuccess: function(transport){ alert(Success); var jsonObj = transport.responseJSON; alert('feelingOk:' + jsonObj['success']); }, onComplete: function(transport){ alert(Complete); } }); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
I can see the Ajax.Request fired off and message response via FireBug. I don't get any alerts though. function ajaxRequest2(){ var url = /cgidev2p/r_chgpwd.pgm; var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F('v_confirm')) + 'sessionid=' + escape($F('sessionid')); //var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: function(transport){ // obtain the json you sent var jsonObj = transport.responseJSON; // use it alert('feelingOk:' + jsonObj['success']); alert('value:' + jsonObj['message']); } }); } Repsonse ... {success : true, message : good} Not sure where to put that application/json response type, but I've seen it before so I'll look it up. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
The success alert fires off, but not the feeling ok alert. function ajaxRequest2(){ var url = /cgidev2p/r_chgpwd.pgm; var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F ('v_confirm')) + 'sessionid=' + escape($F('sessionid')); //var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', contentType: 'application/json', parameters: pars, onSuccess: function(transport){ alert(Success); var jsonObj = transport.responseJSON; alert('feelingOk:' + jsonObj['success']); }, onComplete: function(transport){ alert(Complete); } }); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
If its Json then the alert would be... alert(jsonObj.success); HTH Alex Mcauley http://www.thevacancymarket.com - Original Message - From: mjhaston mjhas...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, October 30, 2009 1:21 PM Subject: [Proto-Scripty] Re: Ajax.Request with JSON response The success alert fires off, but not the feeling ok alert. function ajaxRequest2(){ var url = /cgidev2p/r_chgpwd.pgm; var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F ('v_confirm')) + 'sessionid=' + escape($F('sessionid')); //var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', contentType: 'application/json', parameters: pars, onSuccess: function(transport){ alert(Success); var jsonObj = transport.responseJSON; alert('feelingOk:' + jsonObj['success']); }, onComplete: function(transport){ alert(Complete); } }); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
But you are sending json with the properties 'success' and 'value', and in the callback you use my example code, which tries to alert the values of properties 'feelingOk' and 'value'? Also, make sure you have set the response's content type to application/json. /L On Oct 30, 2:38 am, Michael Haston mich...@haston.name wrote: Didn't seem to work for me. I might have it wrong. Code ... function ajaxRequest2(){ var url = /cgidev2p/r_chgpwd.pgm; var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F('v_confirm')) + 'sessionid=' + escape($F('sessionid')); var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: function(transport){ // obtain the json you sent var jsonObj = transport.responseJSON; // use it alert('feelingOk:' + jsonObj['feelingOk']); alert('value:' + jsonObj['value']); } }); } JSON {success : true, message : good} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
Sorry, I meant to write: But you are sending json with the properties 'success' and 'message', On Oct 30, 9:56 am, Lapis petter.env...@gmail.com wrote: But you are sending json with the properties 'success' and 'value', --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
I think I'd do it more like this, if i just wanted JSON as the response: On the server: set the response type to application/json, something to the equivalent of = response.setContentType(application/json) Then print your json object to the response (java stylee again): writer.print(String.format({value: %d, feelingOk: %s}, 42, Boolean.TRUE)) In the callback, it is handled like this: onComplete : function (transport) { // obtain the json you sent var jsonObj = transport.responseJSON; // use it alert('feelingOk:'+jsonObj['feelingOk']); alert('value:'+jsonObj['value']); } /L --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
What would my json response look like (syntax-wise) in this case? On Thu, 29 Oct 2009 07:28:43 -0700 (PDT), Lapis petter.env...@gmail.com wrote: I think I'd do it more like this, if i just wanted JSON as the response: On the server: set the response type to application/json, something to the equivalent of = response.setContentType(application/json) Then print your json object to the response (java stylee again): writer.print(String.format({value: %d, feelingOk: %s}, 42, Boolean.TRUE)) In the callback, it is handled like this: onComplete : function (transport) { // obtain the json you sent var jsonObj = transport.responseJSON; // use it alert('feelingOk:'+jsonObj['feelingOk']); alert('value:'+jsonObj['value']); } /L --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
From a Java horizon it would be: writer.print({success : true, message : 'good'}); or writer.print({success : false, message : 'bad'}); (writing to the response's PrintWriter) Hoping I am not misinterpreting your question right now. /L On Oct 29, 4:19 pm, mich...@haston.name wrote: What would my json response look like (syntax-wise) in this case? On Thu, 29 Oct 2009 07:28:43 -0700 (PDT), Lapis petter.env...@gmail.com wrote: I think I'd do it more like this, if i just wanted JSON as the response: On the server: set the response type to application/json, something to the equivalent of = response.setContentType(application/json) Then print your json object to the response (java stylee again): writer.print(String.format({value: %d, feelingOk: %s}, 42, Boolean.TRUE)) In the callback, it is handled like this: onComplete : function (transport) { // obtain the json you sent var jsonObj = transport.responseJSON; // use it alert('feelingOk:'+jsonObj['feelingOk']); alert('value:'+jsonObj['value']); } /L --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
Didn't seem to work for me. I might have it wrong. Code ... function ajaxRequest2(){ var url = /cgidev2p/r_chgpwd.pgm; var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F('v_confirm')) + 'sessionid=' + escape($F('sessionid')); var submitObj = document.getElementById('goButton'); new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: function(transport){ // obtain the json you sent var jsonObj = transport.responseJSON; // use it alert('feelingOk:' + jsonObj['feelingOk']); alert('value:' + jsonObj['value']); } }); } JSON {success : true, message : good} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request with JSON response
Found some examples on this site and tried to simplify it. var pars = 'v_current=' + escape($F('v_current')) + 'v_new=' + escape($F('v_new')) + 'v_confirm=' + escape($F('v_confirm')) + 'sessionid=' + escape($F('sessionid')); new Ajax.Request(url, { method: 'get', parameters: pars, onSuccess: function(response){ var json = response.responseJSON; if (!json) { alert('alert 1'); } else { // Good, got JSON data alert('alert 2'); if (json.success) { // Your server-side code says all went well; // you'd probably show json.message, e.g.: alert('alert 3'); v_messege.update(json.message).setStyle({ background: '#dfd' }); } else { // Your server-side code ran correctly, but // returned an error; handle that. alert('alert 4'); } } } }); } My json is either ... {success : true, message : good} or {success : false, message : bad} I never get passed alert 1. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
I checked now in ie 6 its OK tehere is no ie7 around :) Yuval On 8/25/09, Milko Kretschmann mi...@kretschmann.nl wrote: Hi Yuval, Ok, thanks very much. Does it also work under IE7 (6)? Milko. On Aug 25, 2009, at 6:01 AM, yuval dagan wrote: Hi Miko Yes, thats what I checked and it worked great here on ie8. Yuval On Mon, Aug 24, 2009 at 10:56 PM, Milko Kretschmann mi...@kretschmann.nlwrote: Hello Yuval, Thank you very much for checking. Did you also test the url: http://www.cartesians.com/geefeenster/enter_ajax.php If you change country under Delivery Address then the content of the popup behind State/Province should change (via ajax). Thanks again. Milko. On Aug 24, 2009, at 9:25 PM, yuval dagan wrote: hi I checked now at home with ie8 and it works great. I checked also the net renderer with same ie and it didnt worked Yuval On Mon, Aug 24, 2009 at 8:06 PM, Walter Lee Davis wa...@wdstudio.comwrote: Most of the NetRenderers of the world don't process JavaScript and Ajax, unless you spend like a sailor for BrowserCam (where you get to remote into an actual Windows desktop and drive it in real time). One of the reasons I bought a new MacBook Pro last year was so I could install VMWare and run XP and IE6 and see how awful everything could look. Walter On Aug 24, 2009, at 12:33 PM, Milko Kretschmann wrote: Hi Yuval and David, I'm surprised to hear it works under IE6. Since I use MacOS and don't have IE I test it inderectly via a webbased IE renderer ( http://ipinfo.info/netrenderer/index.php ). Here I get a Request Failed message when testing IE6. IE7/8 does not render any result at all. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
You need ietester :) http://www.my-debugbar.com/wiki/IETester/HomePage - Kev yuval dagan wrote: I checked now in ie 6 its OK tehere is no ie7 around :) Yuval On 8/25/09, *Milko Kretschmann* mi...@kretschmann.nl mailto:mi...@kretschmann.nl wrote: Hi Yuval, Ok, thanks very much. Does it also work under IE7 (6)? Milko. On Aug 25, 2009, at 6:01 AM, yuval dagan wrote: Hi Miko Yes, thats what I checked and it worked great here on ie8. Yuval On Mon, Aug 24, 2009 at 10:56 PM, Milko Kretschmann mi...@kretschmann.nl mailto:mi...@kretschmann.nl wrote: Hello Yuval, Thank you very much for checking. Did you also test the url: http://www.cartesians.com/geefeenster/enter_ajax.php If you change country under Delivery Address then the content of the popup behind State/Province should change (via ajax). Thanks again. Milko. On Aug 24, 2009, at 9:25 PM, yuval dagan wrote: hi I checked now at home with ie8 and it works great. I checked also the net renderer with same ie and it didnt worked Yuval On Mon, Aug 24, 2009 at 8:06 PM, Walter Lee Davis wa...@wdstudio.com mailto:wa...@wdstudio.com wrote: Most of the NetRenderers of the world don't process JavaScript and Ajax, unless you spend like a sailor for BrowserCam (where you get to remote into an actual Windows desktop and drive it in real time). One of the reasons I bought a new MacBook Pro last year was so I could install VMWare and run XP and IE6 and see how awful everything could look. Walter On Aug 24, 2009, at 12:33 PM, Milko Kretschmann wrote: Hi Yuval and David, I'm surprised to hear it works under IE6. Since I use MacOS and don't have IE I test it inderectly via a webbased IE renderer (http://ipinfo.info/netrenderer/index.php ). Here I get a Request Failed message when testing IE6. IE7/8 does not render any result at all. -- Kevin Porter Advanced Web Construction Ltd http://webutils.co.uk http://billiardsearch.net http://9ballpool.co.uk AJAX Blackjack - real-time multi-player blackjack game with no flash, java or software downloads required - http://blackjack.webutils.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
Ok. Thanks very much. Milko. On Aug 25, 2009, at 2:17 PM, yuval dagan wrote: I checked now in ie 6 its OK tehere is no ie7 around :) Yuval On 8/25/09, Milko Kretschmann mi...@kretschmann.nl wrote: Hi Yuval, Ok, thanks very much. Does it also work under IE7 (6)? Milko. On Aug 25, 2009, at 6:01 AM, yuval dagan wrote: Hi Miko Yes, thats what I checked and it worked great here on ie8. Yuval On Mon, Aug 24, 2009 at 10:56 PM, Milko Kretschmann mi...@kretschmann.nl wrote: Hello Yuval, Thank you very much for checking. Did you also test the url: http://www.cartesians.com/geefeenster/enter_ajax.php If you change country under Delivery Address then the content of the popup behind State/Province should change (via ajax). Thanks again. Milko. On Aug 24, 2009, at 9:25 PM, yuval dagan wrote: hi I checked now at home with ie8 and it works great. I checked also the net renderer with same ie and it didnt worked Yuval On Mon, Aug 24, 2009 at 8:06 PM, Walter Lee Davis wa...@wdstudio.com wrote: Most of the NetRenderers of the world don't process JavaScript and Ajax, unless you spend like a sailor for BrowserCam (where you get to remote into an actual Windows desktop and drive it in real time). One of the reasons I bought a new MacBook Pro last year was so I could install VMWare and run XP and IE6 and see how awful everything could look. Walter On Aug 24, 2009, at 12:33 PM, Milko Kretschmann wrote: Hi Yuval and David, I'm surprised to hear it works under IE6. Since I use MacOS and don't have IE I test it inderectly via a webbased IE renderer (http://ipinfo.info/netrenderer/index.php ). Here I get a Request Failed message when testing IE6. IE7/8 does not render any result at all. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
Hi Kev, Ok, but this works only under Windows. I use MacOS. Is there a comparable app for Mac? Milko. On Aug 25, 2009, at 3:03 PM, Kevin Porter wrote: You need ietester :) http://www.my-debugbar.com/wiki/IETester/HomePage - Kev yuval dagan wrote: I checked now in ie 6 its OK tehere is no ie7 around :) Yuval On 8/25/09, *Milko Kretschmann* mi...@kretschmann.nl mailto:mi...@kretschmann.nl wrote: Hi Yuval, Ok, thanks very much. Does it also work under IE7 (6)? Milko. On Aug 25, 2009, at 6:01 AM, yuval dagan wrote: Hi Miko Yes, thats what I checked and it worked great here on ie8. Yuval On Mon, Aug 24, 2009 at 10:56 PM, Milko Kretschmann mi...@kretschmann.nl mailto:mi...@kretschmann.nl wrote: Hello Yuval, Thank you very much for checking. Did you also test the url: http://www.cartesians.com/geefeenster/enter_ajax.php If you change country under Delivery Address then the content of the popup behind State/Province should change (via ajax). Thanks again. Milko. On Aug 24, 2009, at 9:25 PM, yuval dagan wrote: hi I checked now at home with ie8 and it works great. I checked also the net renderer with same ie and it didnt worked Yuval On Mon, Aug 24, 2009 at 8:06 PM, Walter Lee Davis wa...@wdstudio.com mailto:wa...@wdstudio.com wrote: Most of the NetRenderers of the world don't process JavaScript and Ajax, unless you spend like a sailor for BrowserCam (where you get to remote into an actual Windows desktop and drive it in real time). One of the reasons I bought a new MacBook Pro last year was so I could install VMWare and run XP and IE6 and see how awful everything could look. Walter On Aug 24, 2009, at 12:33 PM, Milko Kretschmann wrote: Hi Yuval and David, I'm surprised to hear it works under IE6. Since I use MacOS and don't have IE I test it inderectly via a webbased IE renderer (http://ipinfo.info/netrenderer/index.php ). Here I get a Request Failed message when testing IE6. IE7/8 does not render any result at all. -- Kevin Porter Advanced Web Construction Ltd http://webutils.co.uk http://billiardsearch.net http://9ballpool.co.uk AJAX Blackjack - real-time multi-player blackjack game with no flash, java or software downloads required - http://blackjack.webutils.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
hi Im using here ie 6 and it works. but, in ie the dom is ready only when the document is loaded so sometimes refering to an element is impossible before the dom is loaded. try moving the function call to the onload: body onload=setVar('world'); div id=var/div /body On 8/20/09, david david.brill...@gmail.com wrote: Hi Milko, which version of IE, because I test it with IE6, and it wotks. -- david On 18 août, 18:18, milko mi...@kretschmann.nl wrote: Hello, I made an ajax-routine using request and json, which works fine under all browsers except under IE. For the sake of illustration I made a simplified version of this. The link is:http://www.cartesians.com/geefeenster/ajax_test.html It should show the text: Hello world. The code of the (php-) script being called in the routine - ajax_test.php - is as follows: ?php $data['result'] = 'Hello '.$_GET['par']; header('X-JSON: (' . json_encode($data) . ')'); header('Content-type: application/x-json'); echo json_encode($data); ? Can anyone tell why this does not work under IE and what to do to make it work. Many thanks in advance. Milko Kretschmann. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
Hi Milko, which version of IE, because I test it with IE6, and it wotks. -- david On 18 août, 18:18, milko mi...@kretschmann.nl wrote: Hello, I made an ajax-routine using request and json, which works fine under all browsers except under IE. For the sake of illustration I made a simplified version of this. The link is:http://www.cartesians.com/geefeenster/ajax_test.html It should show the text: Hello world. The code of the (php-) script being called in the routine - ajax_test.php - is as follows: ?php $data['result'] = 'Hello '.$_GET['par']; header('X-JSON: (' . json_encode($data) . ')'); header('Content-type: application/x-json'); echo json_encode($data); ? Can anyone tell why this does not work under IE and what to do to make it work. Many thanks in advance. Milko Kretschmann. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and curtain
Hi, Is Ajax.Request somehow queuing up user events and refiring them after the request completes? No, it isn't. On IE7, it sounds as though your curtain div isn't where you think it is in the z order or something like that, and separately the click of the link seems to be being held up by the processing of the request. (Are you talking to a server that only processes a single request in a given session at a time? Search the group for concurrent requests or simultaneous requests for details, there've been a couple of recent threads on that.) You say you're using an onclick handler returning false (e.g., a DOM0 handler). Have you tried using Element#observe[1] and Event#stop[2] instead? I don't know that it would make a difference, but it's more up-to-date and may step around whatever the issue is. This stops and eats clicks on a div called 'curtain': $('curtain').observe('click', function(event) { event.stop(); }); [1] http://prototypejs.org/api/element/observe [2] http://prototypejs.org/api/event/stop HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jun 24, 6:46 pm, sclaflin st...@steveclaflin.com wrote: In IE7: If I create a div as a curtain that hides the rest of the page, but initially hidden, then unhide it before making an Ajax.Request, I find that click events on the curtain seem to get postponed until after the request completes (and my callback hides the curtain again). Which means that if the user clicks on a link in the content beneath the curtain, that click takes effect after the curtain is gone. If I use a plain old XMLHttpRequest to make the request, then the expected behavior occurs (an onclick handler for the curtain div returns false to disable clicking). Behavior is OK in Firefox. Is Ajax.Request somehow queuing up user events and refiring them after the request completes? And, if so, can I override this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request Issue
Hi T.J., thanks for help! Well, i've made the changes you told me to do, including the var name :-) Visualy nothing happend :( I've tried the Ajax.Updater... tried the update()... tried the onSuccess instead onComplete... All of this is too valid, but nothing changed at the end. Could it be anything in HTML code? Like a header missing... wrong doctype... I dont know, just guessing Remembering: its working fine in FF. But the s*** of Internet Explorer simply dont work. The only handler that executes something is the onCreate. Nothing on onFailure and onException. =SSS Regards. On 8 jun, 04:06, T.J. Crowder t...@crowdersoftware.com wrote: Hi Rodrigo, I see two problems there, and separately I have two suggestions. The problems are: 1. You're using the onComplete handler. onComplete is fired when the request is complete for *any reason*, even if it failed. You probably only want to do this when the request is successful, which is the onSuccess handler. (You probably also want to have an onFailure handler so you can tell the user that the request failed; it may be worth looking at this article[1] on the unofficial wiki.) 2. You don't want the 'this' in this line: $('conteudo').innerHTML = this.originalRequest.responseText; Just use: $('conteudo').innerHTML = originalRequest.responseText; ...or even better, using Element#update[2]: $('conteudo').update(originalRequest.responseText); Okay, the suggestions: A) Your variable name originalRequest is misleading, because it's not the request. It's an Ajax.Response object. I suggest the name response. :-) B) Use Ajax.Updater[3] instead of Ajax.Request. Ajax.Updater does almost exactly what you're doing. [1]http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-re... [2]http://prototypejs.org/api/element/update [3]http://prototypejs.org/api/ajax/updater HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jun 8, 4:03 am, Rodrigo Ramos rodrigoramos...@gmail.com wrote: Hey guys, i'm having a trouble with the Ajax.Request method in my code. Could you guys help me out?! Here is the thing: I have a simple html website and i'm just trying to change things using Ajax. The problem is that its working only in FF. On IE simply doesnt work. And, as usual, no error message =S. I'm using the 1.6.0.3 version. I've already tried to debbug printing some alert's inside the method but nothing happend. The object its created (i've put an alert on onCreate) but the .html file never show on screen. You guys have any ideia of what could it be? code: function ajax(url){ var myAjax = new Ajax.Request('conteudo/'+url+'.html', { method : 'get', onComplete: function (originalRequest){ $('conteudo').innerHTML = this.originalRequest.responseText; } }); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request Issue
Well... T.J. I gave up... :-) My deadline for this website was last friday. I've put the old GetXMLHttp function to handle the container update. Its not good looking but its working at least. The problem was the Acess Denied on IE7. But, anyways, thanks for your time! see ya On 8 jun, 18:29, Rodrigo Ramos rodrigoramos...@gmail.com wrote: Hi T.J., thanks for help! Well, i've made the changes you told me to do, including the var name :-) Visualy nothing happend :( I've tried the Ajax.Updater... tried the update()... tried the onSuccess instead onComplete... All of this is too valid, but nothing changed at the end. Could it be anything in HTML code? Like a header missing... wrong doctype... I dont know, just guessing Remembering: its working fine in FF. But the s*** of Internet Explorer simply dont work. The only handler that executes something is the onCreate. Nothing on onFailure and onException. =SSS Regards. On 8 jun, 04:06, T.J. Crowder t...@crowdersoftware.com wrote: Hi Rodrigo, I see two problems there, and separately I have two suggestions. The problems are: 1. You're using the onComplete handler. onComplete is fired when the request is complete for *any reason*, even if it failed. You probably only want to do this when the request is successful, which is the onSuccess handler. (You probably also want to have an onFailure handler so you can tell the user that the request failed; it may be worth looking at this article[1] on the unofficial wiki.) 2. You don't want the 'this' in this line: $('conteudo').innerHTML = this.originalRequest.responseText; Just use: $('conteudo').innerHTML = originalRequest.responseText; ...or even better, using Element#update[2]: $('conteudo').update(originalRequest.responseText); Okay, the suggestions: A) Your variable name originalRequest is misleading, because it's not the request. It's an Ajax.Response object. I suggest the name response. :-) B) Use Ajax.Updater[3] instead of Ajax.Request. Ajax.Updater does almost exactly what you're doing. [1]http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-re... [2]http://prototypejs.org/api/element/update [3]http://prototypejs.org/api/ajax/updater HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jun 8, 4:03 am, Rodrigo Ramos rodrigoramos...@gmail.com wrote: Hey guys, i'm having a trouble with the Ajax.Request method in my code. Could you guys help me out?! Here is the thing: I have a simple html website and i'm just trying to change things using Ajax. The problem is that its working only in FF. On IE simply doesnt work. And, as usual, no error message =S. I'm using the 1.6.0.3 version. I've already tried to debbug printing some alert's inside the method but nothing happend. The object its created (i've put an alert on onCreate) but the .html file never show on screen. You guys have any ideia of what could it be? code: function ajax(url){ var myAjax = new Ajax.Request('conteudo/'+url+'.html', { method : 'get', onComplete: function (originalRequest){ $('conteudo').innerHTML = this.originalRequest.responseText; } }); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and IE 8
Crowder, The results were as i mentioned. Now after the change working in IE 6,7 8. The code is refactored to use asynchronous call. Thanks On Fri, May 29, 2009 at 2:30 PM, T.J. Crowder t...@crowdersoftware.comwrote: Hi, Is there are workaround to get this working in IE 8? Not a workaround, a fix: Don't put false in quotes (in your asynchronous option); it's a flag, not a string. (I'm surprised the results vary, truth be told.) [OT: Do you really, really need the call to be synchronous? You can't refactor? On some browsers, it locks up the UI pretty dramatically.] HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 28, 3:27 pm, Pearls tsponku...@gmail.com wrote: function getSuggestionFromDB(sURL) { var arrResults = new Array(); var objResult; var myAjax = new Ajax.Request( sURL, { method: 'get', asynchronous: 'false', onComplete: function(showResponse) { var resp= showResponse.responseText; var arrSuggestions=resp.split (,); var i; if(arrSuggestions.length ==1 arrSuggestions [0].replace(/^\s+/,).length ==0) { return; } for(i=0;iarrSuggestions.length;i++) { objResult = {}; objResult.id = arrSuggestions[i]; objResult.text = arrSuggestions[i]; arrResults[i] = objResult; } } }); TIME_DELAY_HERE return arrResults; } 1. Here the sURL successfully return 'comma separated values' 2. The above code works fine in IE 6 IE 7 3. In IE 8, arrResults are returned as empty. 4. An TIME_DELAY_HERE ( alert() or manual time delay ) shows up arrResults with correct values. Is there are workaround to get this working in IE 8? Thanks -- Ponkumar S --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and IE 8
Hi, Is there are workaround to get this working in IE 8? Not a workaround, a fix: Don't put false in quotes (in your asynchronous option); it's a flag, not a string. (I'm surprised the results vary, truth be told.) [OT: Do you really, really need the call to be synchronous? You can't refactor? On some browsers, it locks up the UI pretty dramatically.] HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 28, 3:27 pm, Pearls tsponku...@gmail.com wrote: function getSuggestionFromDB(sURL) { var arrResults = new Array(); var objResult; var myAjax = new Ajax.Request( sURL, { method: 'get', asynchronous: 'false', onComplete: function(showResponse) { var resp= showResponse.responseText; var arrSuggestions=resp.split (,); var i; if(arrSuggestions.length ==1 arrSuggestions [0].replace(/^\s+/,).length ==0) { return; } for(i=0;iarrSuggestions.length;i++) { objResult = {}; objResult.id = arrSuggestions[i]; objResult.text = arrSuggestions[i]; arrResults[i] = objResult; } } }); TIME_DELAY_HERE return arrResults; } 1. Here the sURL successfully return 'comma separated values' 2. The above code works fine in IE 6 IE 7 3. In IE 8, arrResults are returned as empty. 4. An TIME_DELAY_HERE ( alert() or manual time delay ) shows up arrResults with correct values. Is there are workaround to get this working in IE 8? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
global how .. that doesnt really explain much If you mean globaly accessible to javascript then you need to do something like ?php $bar='bar'; echo(scriptfoo=$bar/script); ? scriptalert(foo);/script ... otherwise please be more specific Thanks Alex - Original Message - From: marioosh marioosh@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, March 03, 2009 12:38 PM Subject: [Proto-Scripty] Ajax.Request and php global variable I have a code as below: test1.php: -- html head meta http-equiv=Content-Type content=text/html; charset=UTF-8 script type=text/javascript src=resources/scriptaculous- js-1.8.2/lib/prototype.js /script script type=text/javascript src=test1.js /script /head body ?php // want to be global, but how??? $var = 'test'; ? div id=debug/div /body /html test1.js: -- Event.observe(document,'dom:loaded', function() { new Ajax.Updater('debug','test2.php', { onComplete: function() { } }); }); test2.php: -- ?php echo var = .$var; ? (http://pastie.org/405875 for better view) How to make $var to work as global within Ajax.Request ?? Is this possible ? Thanks in advance for help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
Or if you mean passing the contents of the php variable $var to 'test2.php' then you can do so like this -- in your JS Event.observe(document,'dom:loaded', function() { new Ajax.Updater('debug','test2.php', { parameters : {var: '?php echo($var); ?',anotherParam: 'blah',yetAnotherParam: 'Boing'}, onComplete: function(transport) { var data=transport.responseText;alert(data);} }); }); HTH Alex - Original Message - From: Alex Mcauley webmas...@thecarmarketplace.com To: prototype-scriptaculous@googlegroups.com Sent: Tuesday, March 03, 2009 1:06 PM Subject: [Proto-Scripty] Re: Ajax.Request and php global variable global how .. that doesnt really explain much If you mean globaly accessible to javascript then you need to do something like ?php $bar='bar'; echo(scriptfoo=$bar/script); ? scriptalert(foo);/script ... otherwise please be more specific Thanks Alex - Original Message - From: marioosh marioosh@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, March 03, 2009 12:38 PM Subject: [Proto-Scripty] Ajax.Request and php global variable I have a code as below: test1.php: -- html head meta http-equiv=Content-Type content=text/html; charset=UTF-8 script type=text/javascript src=resources/scriptaculous- js-1.8.2/lib/prototype.js /script script type=text/javascript src=test1.js /script /head body ?php // want to be global, but how??? $var = 'test'; ? div id=debug/div /body /html test1.js: -- Event.observe(document,'dom:loaded', function() { new Ajax.Updater('debug','test2.php', { onComplete: function() { } }); }); test2.php: -- ?php echo var = .$var; ? (http://pastie.org/405875 for better view) How to make $var to work as global within Ajax.Request ?? Is this possible ? Thanks in advance for help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
Alex Mcauley wrote: global how .. that doesnt really explain much If you mean globaly accessible to javascript then you need to do something like ?php $bar='bar'; echo(scriptfoo=$bar/script); ? marioosh, you also need to properly quote strings, or convert php variables to javascript notation. Easiest way to do this is to use json_encode() function: ?php $bar='bar'; echo (scriptfoo= . json_encode($bar) . /script); ? Which will give you something like: scriptfoo=bar/script If $bar was an array, eg $bar=array('one','two'), the json_encode function would also convert it to javascript notation: [one, two]; Regards, SWilk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
And how about $var is an php object of some class ? $var = new Foo(); Is possible to pass $var by: parameters : {var: '?php echo($var); ?', } ?? On 3 Mar, 14:10, Alex Mcauley webmas...@thecarmarketplace.com wrote: Or if you mean passing the contents of the php variable $var to 'test2.php' then you can do so like this -- in your JS Event.observe(document,'dom:loaded', function() { new Ajax.Updater('debug','test2.php', { parameters : {var: '?php echo($var); ?',anotherParam: 'blah',yetAnotherParam: 'Boing'}, onComplete: function(transport) { var data=transport.responseText;alert(data); } });}); HTH Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
Explaining [sorry for my english ;)]: I need $var that is object of some class, and $var will point to the same object in test1.php, test2.php, test3.php ... where: test1.php, test2.php ... are scripts that will be used in new Ajax.Request(... I need something like above. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
Quoting does not allways matter when setting javascript vars ... Plus not every version of php has json_encode() installed on it Thanks Alex - Original Message - From: Szymon Wilkołazki wilkola...@gmail.com To: prototype-scriptaculous@googlegroups.com Sent: Tuesday, March 03, 2009 1:17 PM Subject: [Proto-Scripty] Re: Ajax.Request and php global variable Alex Mcauley wrote: global how .. that doesnt really explain much If you mean globaly accessible to javascript then you need to do something like ?php $bar='bar'; echo(scriptfoo=$bar/script); ? marioosh, you also need to properly quote strings, or convert php variables to javascript notation. Easiest way to do this is to use json_encode() function: ?php $bar='bar'; echo (scriptfoo= . json_encode($bar) . /script); ? Which will give you something like: scriptfoo=bar/script If $bar was an array, eg $bar=array('one','two'), the json_encode function would also convert it to javascript notation: [one, two]; Regards, SWilk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
marioosh wrote: Explaining [sorry for my english ;)]: I need $var that is object of some class, and $var will point to the same object in test1.php, test2.php, test3.php ... where: test1.php, test2.php ... are scripts that will be used in new Ajax.Request(... I need something like above. Then you need to read about Sessions in PHP. http://pl.php.net/manual/en/book.session.php Regards, SWilk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
I am not sure that you can pass objects from php to javascript and back again ... You can pass javascript objects from php to javascript with serialization but i dont think php objects will pass correctly ... Perhaps there is a better way to do what you want, could you explain what you are trying to achieve and perhaps we can help Regards Alex - Original Message - From: marioosh marioosh@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, March 03, 2009 1:34 PM Subject: [Proto-Scripty] Re: Ajax.Request and php global variable Explaining [sorry for my english ;)]: I need $var that is object of some class, and $var will point to the same object in test1.php, test2.php, test3.php ... where: test1.php, test2.php ... are scripts that will be used in new Ajax.Request(... I need something like above. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
Alex Mcauley pisze: Quoting does not allways matter when setting javascript vars ... Plus not every version of php has json_encode() installed on it Yeah, your right. To much of intranet coding, when you know exactly what you have on server, and if there's something you need and it's not on server, a few emails are usually enaugh for it to be enabled. Regards, SWilk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
I dont think sessions will cut it if he is trying to move around php objects async, process them and or add to them and return the same object ... - is all depends on what he is trying to do but for instance to set a session variable in PHP then retrieve that session variable later on in a script requires another ajax request to set a javascript variable to then check if the session has changed or to query the value again which is expensive - Original Message - From: Szymon Wilkołazki wilkola...@gmail.com To: prototype-scriptaculous@googlegroups.com Sent: Tuesday, March 03, 2009 1:37 PM Subject: [Proto-Scripty] Re: Ajax.Request and php global variable marioosh wrote: Explaining [sorry for my english ;)]: I need $var that is object of some class, and $var will point to the same object in test1.php, test2.php, test3.php ... where: test1.php, test2.php ... are scripts that will be used in new Ajax.Request(... I need something like above. Then you need to read about Sessions in PHP. http://pl.php.net/manual/en/book.session.php Regards, SWilk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and php global variable
marioosh : a word of warning if using json_encode / decode in php ... Some servers (my test server) added slashes to json from an ajax request and my work server didn't ( 2 linux servers with same setup gve or take 0.1 of a php RC !! so beware and add/stripslashes !! Alex - Original Message - From: Szymon Wilkołazki wilkola...@gmail.com To: prototype-scriptaculous@googlegroups.com Sent: Tuesday, March 03, 2009 1:41 PM Subject: [Proto-Scripty] Re: Ajax.Request and php global variable Alex Mcauley pisze: Quoting does not allways matter when setting javascript vars ... Plus not every version of php has json_encode() installed on it Yeah, your right. To much of intranet coding, when you know exactly what you have on server, and if there's something you need and it's not on server, a few emails are usually enaugh for it to be enabled. Regards, SWilk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.request is not sending back the response with Safari browser using Iframe. The same works perfectly with IE and firefox.
Hi David, Below is the code: Java script function in the Iframe is: function addStudentInfo() { var dataObjArr = new Array(); var studJson1 = {name: Stud1, age: 21, gender: Male, course : Physics, location: XYZ}; var studJson2 = {name: Stud2, age: 22, gender: Female, course : Chemistry, location: XYZ}; var studJson3 = {name: Stud3, age: 23, gender: Male, course : Matchs, location: XYZ}; dataObjArr.push(studJson1) dataObjArr.push(studJson2) dataObjArr.push(studJson3) parent.processStudentFromIframe(dataObjArr); } java script function in the parent page, which basically creates a Ajax request, adds the student to Database and updates the display. function processStudentFromIframe(dataObj) { var studParamAttributes = ; for(var a = 0; a dataObj.length; a++) { studParamAttributes = studParamAttributes + dataObj[a].name + ~~ + dataObj[a].age + ~~ + dataObj[a].gender + ~~ + dataObj[a].course + ~~ + dataObj[a].location; studParamAttributes = studParamAttributes + ,; } //removing the last trailing comma. studParamAttributes = studParamAttributes.replace(/^,+|,+$/, ''); var searchParam =cmd=ProfileControllerstudentParamAttributes= + studParamAttributes + action=addStudentFromIframe; showProgress(); var url = ./ab; new Ajax.Request(url, { method:'post', parameters:searchParam, onComplete: function(request) { hideProgress(); updateMessageAndStudentSummary(request); } } ); } Parent page function is getting called and showprogress function displayed the progress bar but since the response never comes back from Ajax.request, page simply gets hanged with the progress bar display. -- Atif On Feb 12, 4:21 pm, david david.brill...@gmail.com wrote: Hi, Atif, is it possible to have the code, because it could be a problem in Safari. Safari have some hidden bug, it could be that. -- david On 12 fév, 10:58, Atif atif.siddiq...@gmail.com wrote: Hi, I am using prototype and scriptaculous in my application. Normally all the functionalities works fine with all the browsers. Current situation is I have a parent page in JSP which is having an Iframe with an src of a PHP page. After doing some search in the Iframe page I am calling a parent page function which is basicaly calling ajax and updating the UI. Ajax request is going properly but I never get the response back. The screen simply get hanged. Thanks and regards, Atif Ahmad Siddiqui.- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.request is not sending back the response with Safari browser using Iframe. The same works perfectly with IE and firefox.
Hi, Atif, is it possible to have the code, because it could be a problem in Safari. Safari have some hidden bug, it could be that. -- david On 12 fév, 10:58, Atif atif.siddiq...@gmail.com wrote: Hi, I am using prototype and scriptaculous in my application. Normally all the functionalities works fine with all the browsers. Current situation is I have a parent page in JSP which is having an Iframe with an src of a PHP page. After doing some search in the Iframe page I am calling a parent page function which is basicaly calling ajax and updating the UI. Ajax request is going properly but I never get the response back. The screen simply get hanged. Thanks and regards, Atif Ahmad Siddiqui. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request delay
Hi, Ajax requests are *asynchronous*; more in this recent thread: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/6b593cf7e6be236c/bf42fddc38f2d8c5 HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jan 26, 6:58 pm, RobDiablo frew.rob...@gmail.com wrote: Hello, I'm having a weird issue when trying to use Ajax.Request in a function within a function. I'm using LiveValidation fromhttp://www.livevalidation.com/which uses prototype.js. It has a custom attribute that allows you to pass in a custom function to validate against. I call this custom function so that I can check a username against a database using the Ajax.Request method. The way it should work is, if the username is not found, it returns true, otherwise false. I haven't been able to get that exact result so I've created some workarounds. True or False is passed to the custom function of LiveValidation and validates based on true or false. However, for some reason, there is a delay in passing the value from the LiveValidation custom function. So let's say the username bee is taken. As I type the word 'bee' and the LiveValidation is being passed to the Ajax.Method, it is returning false. If I continue to type, let's say to the word 'beer,' it finally comes back true, even though 'beer' is not taken. Once I leave that field for the next one, it validates again and comes back false for the word 'beer.' Thus the delay. Here is the code I am using for the Ajax.Request function: * function validateEntry(c,f) { var url = ajaxProcessor.php?f= + f + c= + c; new Ajax.Request(url, { method: 'post', onComplete: function(transport) { if (transport.responseText == YES){ return entryResponse = 1; }else{ return entryResponse = 0; } } }); if (entryResponse == 0) { return false; }else{ return true; }} I'm using entryResponse because I haven't figured out how to return true or false. Here is the custom function for LiveValidation: script type=text/javascript var f1 = new LiveValidation('f1', { validMessage: Ok! } ); f1.add( Validate.Custom, { against: function(value){ return validateEntry(value,3) }, failureMessage: Username already taken! } ); /script *** Now I tested to see if it was the LiveValidation that was causing the delay in sending the correct value to the Ajax.Request function and it's not. Somewhere within the Ajax.Request method, the return values are being delayed. Can anyone help? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request unload
Thanks for responding, and checking the code. i guess i should have noted: i'm also using FirePHP, so there are lines in place sending debug log lines back to Firebug. However, on only this particular call, absolutely nothing gets sent back from the server. Not even a log line saying the PHP script was executed. No SOP violation (Internal.fileList.Path is correct), i've adjusted all Internal references to be prefixed by window, though you are correct, there are no other Internal objects in that context. In a bizarre twist, if i create a new button in my application and observe click to the EXACT same block of code, it executes flawlessly. -joe t. On Jan 8, 5:27 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Joe, The client-side code looks okay to this second pair of eyes. (You might want to put window. in front of Internal in the Ajax.Request constructor, just for consistency as you've done it everywhere else. But I'm assuming you don't have some other Internal defined in scope, and so it should be using the same one anyway.) I'd suggest the usual things: Check that window.Internal.fileList.Path really has the correct path and that it's not violating SOP; temporarily try replacing that path with a static file path to eliminate issues in the server-side processing; put debugging checks on the server-side resource it's calling; the usual sort of stuff. I suspect an issue with the server-side resource. But the client-side part looks okay, FWIW. -- T.J. Crowder tj / crowder software / com On Jan 7, 6:59 pm, joe t. thooke...@gmail.com wrote: i have the following: Event.observe(window,'unload',function(){ if (window.Internal window.Internal.doUnload){ (new Ajax.Request(Internal.fileList.Path,{ asynchronous:false, method:get, parameters:{do:unload,task:$_GET.p}, onSuccess:function(t){alert('Success: ' + t.responseText);} })); alert('Wait!'); } }); The Wait alert at the end is just for testing. It does fire. The problem is, the Ajax call does not seem to work at all. Firebug tells me the Ajax block is executed, the onSuccess alert even fires. But t.responseText is always empty, and the actions i've defined in my server-side code are not happening. Any takers to try helping me track this down? -joe t. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request unload
i presume the page hasn't already unloaded, because the document is still visible, Firebug can still break at my designated markers, the alert('Wait!') line still executes AFTER the Ajax call, and only after i clear the alert does the page actually clear. Being that i'm setting {asynchronous:false}, i believe that alert won't execute until the Ajax is complete. If i place this particular block in beforeunload, i have no way to tell the PHP if the user has elected to continue unloading or has canceled the unload. The PHP in this case cleans up files the user has uploaded while on this page. Since i can't utilize the beforeunload confirm's return value, the user's files would get cleaned up even if they cancel the unload. -joe t. On Jan 8, 9:47 am, Walter Lee Davis wa...@wdstudio.com wrote: Perhaps the unload event has already happened and the page is gone? What happens if you change this event to beforeunload? Walter On Jan 8, 2009, at 9:41 AM, joe t. wrote: Event.observe(window,'unload',function(){ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request unload
DAMMIT! i found the bugger. It was a similar piece of PHP in a different file that gets called when the page LOADS! Everything was getting cleaned up before the piece i'm examining could ever happen. By the way, Firebug WAS reporting the FirePHP logs. It just happens that it was displaying them when the next page loaded. Kinda weird, easy to miss. Anyway, thanks to both of you for your help. -joe t. On Jan 8, 10:41 am, joe t. thooke...@gmail.com wrote: i presume the page hasn't already unloaded, because the document is still visible, Firebug can still break at my designated markers, the alert('Wait!') line still executes AFTER the Ajax call, and only after i clear the alert does the page actually clear. Being that i'm setting {asynchronous:false}, i believe that alert won't execute until the Ajax is complete. If i place this particular block in beforeunload, i have no way to tell the PHP if the user has elected to continue unloading or has canceled the unload. The PHP in this case cleans up files the user has uploaded while on this page. Since i can't utilize the beforeunload confirm's return value, the user's files would get cleaned up even if they cancel the unload. -joe t. On Jan 8, 9:47 am, Walter Lee Davis wa...@wdstudio.com wrote: Perhaps the unload event has already happened and the page is gone? What happens if you change this event to beforeunload? Walter On Jan 8, 2009, at 9:41 AM, joe t. wrote: Event.observe(window,'unload',function(){ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request add a toString method
Maybe you could describe this feature in some form (could be more generic to other Prototype objects) in the documentation. I'm assuming Object.inspect uses the toString method. I agree with you that debugging features should be stripped, if such a debug version would be created, implementation of the toString method of several classes could be added... On Nov 7, 5:34 pm, T.J. Crowder [EMAIL PROTECTED] wrote: FWIW, although I think it's a neat idea, I don't think I'd want to see it in Prototype itself. I think it's more of a debugging thing. (Granted Prototype has some other debugging things; I'd like to strip those out of the release version as well...) -- T.J. Crowder tj / crowder software / com On Nov 7, 3:49 pm, kangax [EMAIL PROTECTED] wrote: On Nov 7, 9:08 am, jaap.taal [EMAIL PROTECTED] wrote: I'd like a toString method for an Ajax.Request object that can identify the request for logging purposes. Right now I'm using the following custom code: Ajax.Request.prototype.toString = function() { if (this.method == 'get') { And what if it's PUT or DELETE? return this.url + (GET); } else { return this.url + ? + $H(this.parameters).toQueryString() + (POST); } }; I think something like this ought to be in the prototype library. I don't remember anyone proposing such thing : ) You can create a ticket (marking it as an enhancement) but I'm afraid what the output of `toString` should be is a pretty subjective decision. I think it's easy enough to write one (as you did) and tailor it to your specific need. -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request add a toString method
Best fit for this would be an inspect method. Have a look at the rest of the framework and at Ruby to see how this is generally implemented. Best, Tobie On Nov 8, 4:09 pm, jaap.taal [EMAIL PROTECTED] wrote: On Nov 7, 4:49 pm, kangax [EMAIL PROTECTED] wrote: On Nov 7, 9:08 am, jaap.taal [EMAIL PROTECTED] wrote: I'd like a toString method for an Ajax.Request object that can identify the request for logging purposes. Right now I'm using the following custom code: Ajax.Request.prototype.toString = function() { if (this.method == 'get') { And what if it's PUT or DELETE? I said something like this :) I'm not using PUT and DELETE in my application, so this was enough for me. return this.url + (GET); } else { return this.url + ? + $H(this.parameters).toQueryString() + (POST); } }; I think something like this ought to be in the prototype library. I don't remember anyone proposing such thing : ) You can create a ticket (marking it as an enhancement) but I'm afraid what the output of `toString` should be is a pretty subjective decision. I think it's easy enough to write one (as you did) and tailor it to your specific need. -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and text/javascript = syntax errors in javascript
Hi, You're looking for the onException callback[1]. If an exception occurs during script evaluation (or for any other reason during the processing of the request), onException is called. You might want to check ou the Bulletproof Ajax Requests How To in the unofficial wiki[2], although what's there so far is just a start. [1] http://prototypejs.org/api/ajax/options [2] http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-requests HTH, -- T.J. Crowder tj / crowder software / com On Nov 7, 2:14 pm, jaap.taal [EMAIL PROTECTED] wrote: That's not what I want. I want to serve text/javascript but when I'm using a dynamically generated script which contains syntax errors I'm not notified by Prototype. On Nov 6, 8:57 pm, Diodeus [EMAIL PROTECTED] wrote: Serve it as text/html. On Nov 6, 2:06 pm, jaap.taal [EMAIL PROTECTED] wrote: I'm using Ajax.Request and receive a text/javascript content-type, but sometimes I make a syntax error in my javascript. The error is now silently ignored (at least that's what I think). Using firebug it doesn't show in my console window. new Ajax.Request('myscript.php', { method:'get', paramters: {...} }); Response: HTTP/1.1 200 OK Date: Thu, 06 Nov 2008 18:56:06 GMT Server: Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch X-Powered-By: PHP/5.2.6-5 Set-Cookie: PHPSESSID=...; path=/ Content-Length: 195 Connection: close Content-Type: text/javascript alert('testing'; How can I trap this error when I'm using prototype?? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request add a toString method
FWIW, although I think it's a neat idea, I don't think I'd want to see it in Prototype itself. I think it's more of a debugging thing. (Granted Prototype has some other debugging things; I'd like to strip those out of the release version as well...) -- T.J. Crowder tj / crowder software / com On Nov 7, 3:49 pm, kangax [EMAIL PROTECTED] wrote: On Nov 7, 9:08 am, jaap.taal [EMAIL PROTECTED] wrote: I'd like a toString method for an Ajax.Request object that can identify the request for logging purposes. Right now I'm using the following custom code: Ajax.Request.prototype.toString = function() { if (this.method == 'get') { And what if it's PUT or DELETE? return this.url + (GET); } else { return this.url + ? + $H(this.parameters).toQueryString() + (POST); } }; I think something like this ought to be in the prototype library. I don't remember anyone proposing such thing : ) You can create a ticket (marking it as an enhancement) but I'm afraid what the output of `toString` should be is a pretty subjective decision. I think it's easy enough to write one (as you did) and tailor it to your specific need. -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request add a toString method
On Nov 7, 9:08 am, jaap.taal [EMAIL PROTECTED] wrote: I'd like a toString method for an Ajax.Request object that can identify the request for logging purposes. Right now I'm using the following custom code: Ajax.Request.prototype.toString = function() { if (this.method == 'get') { And what if it's PUT or DELETE? return this.url + (GET); } else { return this.url + ? + $H(this.parameters).toQueryString() + (POST); } }; I think something like this ought to be in the prototype library. I don't remember anyone proposing such thing : ) You can create a ticket (marking it as an enhancement) but I'm afraid what the output of `toString` should be is a pretty subjective decision. I think it's easy enough to write one (as you did) and tailor it to your specific need. -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and text/javascript = syntax errors in javascript
That's not what I want. I want to serve text/javascript but when I'm using a dynamically generated script which contains syntax errors I'm not notified by Prototype. On Nov 6, 8:57 pm, Diodeus [EMAIL PROTECTED] wrote: Serve it as text/html. On Nov 6, 2:06 pm, jaap.taal [EMAIL PROTECTED] wrote: I'm using Ajax.Request and receive a text/javascript content-type, but sometimes I make a syntax error in my javascript. The error is now silently ignored (at least that's what I think). Using firebug it doesn't show in my console window. new Ajax.Request('myscript.php', { method:'get', paramters: {...} }); Response: HTTP/1.1 200 OK Date: Thu, 06 Nov 2008 18:56:06 GMT Server: Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch X-Powered-By: PHP/5.2.6-5 Set-Cookie: PHPSESSID=...; path=/ Content-Length: 195 Connection: close Content-Type: text/javascript alert('testing'; How can I trap this error when I'm using prototype?? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request charset encoding problems
Hi, Weird, in the space of just a few days we've now had three separate threads on character encoding, more than we've had in several months. Here are the other two threads: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/06f7ab84ec0e7178 http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/2d721cacad30d9e7 Might be worth teaming up with the other people having similar problems... Sorry not to have an answer for you, -- T.J. Crowder tj / crowder software / com On Oct 22, 12:02 am, d_idaho [EMAIL PROTECTED] wrote: Hi, I'm using prototype 1.6.0.2. My page is generated by a cgi-bin program (a dll) on a IIS server. It is encoded in Windows-1252 charset. Users may both use Internet Explorer 6 or Mozilla Firefox browsers. The page uses the Ajax.Request object in order to send a request to the dll : new Ajax.Request( http://myUpfrontserver/cognos/cgi-bin/ upfisapi.dll, { method: 'post', parameters: {xmlcmd: DescribeNewsBoxID123443435454534/ID/ DescribeNewsBox}, encoding: ''Windows-1252', contentType: application/x-www-form-urlencoded, onSuccess: function(transport) { /* My treatment on transport.responseXML or transport.responseText */ } }); The server returns an xml message supposed to be encoded in Windows-1252 charset. But it seems the transport response is interpreted as encoded in UTF-8 charset... Actually, some accented character and their related characters appear with a ? i.e; : aï becomes a? (this is the U+FFFD character, which appears in a dark square on Firefox, and as ? on IE6) If I directly use the XMLHttpRequest object, I do not have this kind of problem on Firefox (the problem persists with IE6) : the responseText content is well detected in Windows-1252 charset. Do you know if the Ajax objects enforces the response to be detected as encoded in UTF-8? Is there any way to change this? I tried to analyze the prototype script in order to find where, in the Ajax class, the responseText could be encoded in UTF-8 but I could not find it... Anyway, I found that as the load was not completed, my responseText was correctly interpreted (accented characters appear correctly), and it is only at the end of the load when the status is complete, that the U+FFFD Unicode characters appear. Moreover, with IE6, I meet this problem by using both Ajax.Request or XMLHttpRequest... Is there a way to enforce encoding of the XMLHttpRequest response ? Thanks for your help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.request problem
I suppose 'secid','Name' and 'cIns' are input elements from your 'trainingForm' form? Why don't you use the serialize() method from the Form object in order to send the parameters ? *ie*: var url = 'courseSecIdUpdate.php'; new Ajax.Request(url, { method: 'post', parameters: $('trainingForm').serlialize(), onSuccess: function(transport) { if(transport.status != 200) { alert(transport.status); } } onFailure: function(transport1) { alert('Did not work'); alert(transport1.readyState); } }); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.request problem
I see an error in your code which could have prevented it from working at all; the ',' (comma) after the onSuccess function definition is missing (happens to me all to frequently :)) - could that be the issue or is it a typo? I'd suggest you to use some kind of debugger for spotting that kind of issues. Personally, I'm using FireBug for Firefox - it shows if there were any Javascript errors and lets you inspect AJAX requests easily. - Baglan p.s. Here's the link for the Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request, parameterrs, JSON, and ASP.NET - Invalid JSON primitive
Hi Maulkye, You set the application/json in the client call, but it is the response from the server that should send this info. Is it the case? Next, It seems that the JSON is not very well formatted, asOK is not a good JSON value, try a good JSON ? And my last remark is that it seems to be a server side problem ?? not a real PROTOTYPE problem -- david. On Sep 4, 2:31 am, Maulkye [EMAIL PROTECTED] wrote: Hello all, I keep getting this error message (Invalid JSON primitive) when I try to call an Ajax.Request with the 'applicatio/json' content type. I've tried formatting the parameters in a variety of ways, but no luck. Can anyone help? Here's what I have: CLIENT: new Ajax.Request(/myService.asmx/GetComplexData,{ onSuccess: onSuccess, onFailure: onFailure, method:post, contentType:application/json; charset=utf-8, parameters: {s: 'bob'} }); SERVER: [WebMethod] public string GetComplexData(string s) { return s; } Note that other calls are working. If I remove the content type, this woks ok, but it just populates the string parameter with the value of s from the client. Additionally, I tried this on the server, but to no avail: [WebMethod] public string GetComplexData(object s) { return ok; } It seems like there's some way I'm supposed to format the parameters to make MS.NET happy, but I can't figure out how it is. The server can obviously handle it, because if I use their big fat client library it sends json objects over and puts them into a dictionary object without a hitch. If anyone can offer some suggestions of even point in the right direction, I would be most appreciative. Thanks, -M Full Error Message: - {Message:Invalid JSON primitive: s.,StackTrace: at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() \r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T] (String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData),ExceptionType:System.ArgumentException} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request, parameterrs, JSON, and ASP.NET - Invalid JSON primitive
Hi Maulkye, Just off the top of my head, does your JSON looks like this: { thingy: value } or like this: { thingy: value } The former is not valid JSON syntax. It is valid JavaScript object literal syntax, but not JSON, which is a _subset_ of object literal syntax. The only primitive values (e.g., things you leave out of quotes) in JSON are false, true, and null. So if you're not putting quotes around the things on the left, you might try that to see if it's the problem. Maybe the MS parser is being picky. HTH, -- T.J. Crowder tj / crowder software / com On Sep 4, 1:31 am, Maulkye [EMAIL PROTECTED] wrote: Hello all, I keep getting this error message (Invalid JSON primitive) when I try to call an Ajax.Request with the 'applicatio/json' content type. I've tried formatting the parameters in a variety of ways, but no luck. Can anyone help? Here's what I have: CLIENT: new Ajax.Request(/myService.asmx/GetComplexData,{ onSuccess: onSuccess, onFailure: onFailure, method:post, contentType:application/json; charset=utf-8, parameters: {s: 'bob'} }); SERVER: [WebMethod] public string GetComplexData(string s) { return s; } Note that other calls are working. If I remove the content type, this woks ok, but it just populates the string parameter with the value of s from the client. Additionally, I tried this on the server, but to no avail: [WebMethod] public string GetComplexData(object s) { return ok; } It seems like there's some way I'm supposed to format the parameters to make MS.NET happy, but I can't figure out how it is. The server can obviously handle it, because if I use their big fat client library it sends json objects over and puts them into a dictionary object without a hitch. If anyone can offer some suggestions of even point in the right direction, I would be most appreciative. Thanks, -M Full Error Message: - {Message:Invalid JSON primitive: s.,StackTrace: at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() \r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T] (String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData),ExceptionType:System.ArgumentException} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request, parameterrs, JSON, and ASP.NET - Invalid JSON primitive
Hi and thanks for you response, I have been having trouble with google not posting my messages, so I accidentally posted this issue twice. Additionally, the lengthy solution I posted to the porblem disappeared as well. I don't know why, but I'd rather not post it again. At any rate, you are correct in that I just never got the JSON format right. In the end, the biggest error I made was not including the parameter in the JSON: This format proved successful worked: '{p_Person: {__type:WebServiceCalls.Person,firstName:John,lastName:Smith,greeting:Hello}}' Thanks, Maulkye On Sep 10, 8:21 am, T.J. Crowder [EMAIL PROTECTED] wrote: HiMaulkye, Just off the top of my head, does your JSON looks like this: { thingy: value } or like this: { thingy: value } The former is not valid JSON syntax. It is valid JavaScript object literal syntax, but not JSON, which is a _subset_ of object literal syntax. The only primitive values (e.g., things you leave out of quotes) in JSON are false, true, and null. So if you're not putting quotes around the things on the left, you might try that to see if it's the problem. Maybe the MS parser is being picky. HTH, -- T.J. Crowder tj / crowder software / com On Sep 4, 1:31 am,Maulkye[EMAIL PROTECTED] wrote: Hello all, I keep getting this error message (Invalid JSON primitive) when I try to call an Ajax.Request with the 'applicatio/json' content type. I've tried formatting the parameters in a variety of ways, but no luck. Can anyone help? Here's what I have: CLIENT: new Ajax.Request(/myService.asmx/GetComplexData,{ onSuccess: onSuccess, onFailure: onFailure, method:post, contentType:application/json; charset=utf-8, parameters: {s: 'bob'} }); SERVER: [WebMethod] public string GetComplexData(string s) { return s; } Note that other calls are working. If I remove the content type, this woks ok, but it just populates the string parameter with the value of s from the client. Additionally, I tried this on the server, but to no avail: [WebMethod] public string GetComplexData(object s) { return ok; } It seems like there's some way I'm supposed to format the parameters to make MS.NET happy, but I can't figure out how it is. The server can obviously handle it, because if I use their big fat client library it sends json objects over and puts them into a dictionary object without a hitch. If anyone can offer some suggestions of even point in the right direction, I would be most appreciative. Thanks, -M Full Error Message: - {Message:Invalid JSON primitive: s.,StackTrace: at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() \r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T] (String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData),ExceptionType:System.ArgumentException}- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---