[Proto-Scripty] Re: Ajax.Request
Add a timestamp parameter to your Ajax call to break the cache... AND STOP YELLING! On Jan 16, 5:04 am, dileep wrote: > FOR IE 7 AJAX.REQUEST IS NOT GETTING VALUES UPDATED FROM SERVER.I NEED > TO SERVE THE CURRENT SERVER TIME AND SOME OTHER VALUES FROM SERVER AS > A JSON STRING .THIS PART OF THE MY SCRIPT IS WORKING WELL WITH FIREFOX > OPERA NETSCAPE .BUT WITH IE IT ALWAYS SHOWS THE VALUES SAME AS THE > FIRST AJAX CALL DURING THE PAGE LOAD.THE FREEQUENCY FOR AJAX CALL IS 5 > SECOND. > > ANY HAVE AN IDEA .PLEASE SEND ME --~--~-~--~~~---~--~~ 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 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 problem
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 <[EMAIL PROTECTED]> 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 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 & unload
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." 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
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" 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." 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
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
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 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." 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 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 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 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: > > > > > var f1 = new LiveValidation('f1', { validMessage: "Ok!" } ); > f1.add( Validate.Custom, { against: function(value){ return > validateEntry(value,3) }, failureMessage: "Username already > taken!" } ); > > > *** > > 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 and timeouts
Hey Matthew, I ran into that issue as well, where you're not really expecting the onSuccess event as its timed out, inherently an error has occurred, as the server has taken longer than allowed. Take a look at my approach to a resolution to this problem in my solution to implementing timeout behavior for Ajax.Request. http://positionabsolute.net/blog/2008/07/prototype-ajax-request-timeout.php On Dec 3, 4:18 pm, Matthew Reed <[EMAIL PROTECTED]> wrote: > Hello everyone. > > I apologize if this matter has already been dealt with. > I need to make ajax calls and manage transmission timeouts, so I > cutandpasted codejanitor's code > :http://codejanitor.com/wp/2006/03/23/ajax-timeouts-with-prototype/. > > It works but I noticed that calling request.transport.abort(); > triggers onSuccess callback in any case! You can easily reproduce this > behaviour ptting some alert in onSuccess inside an Ajax.Request call. > > I was wondering if this behaviour of Ajax.Request is wanted or is a > bug of sort. > > Thanks for your answers. --~--~-~--~~~---~--~~ 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: "123443435454534 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 charset encoding problems
Hi, The same problem happened with me, and I found a possible solution. View the thread below for details: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/06f7ab84ec0e7178 :D 2008/10/22 T.J. Crowder <[EMAIL PROTECTED]> > > 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: "123443435454534 > 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 EvalScripts IE only Bug
mtm81 wrote: > using the Ajax.Request method trying to eval scripts won't work. Works > without issue in FF and safari (Win) > > Main page calls an AJAX.Update with evalscripts true. resulting > content calls an AJAX.AutoComplete with afterUpdateElement function > > function calls the Ajax request and resulting content has a simple JS > Alert script. > > In FF and Safari this fires without any problems.. in IE7 this does > not fire. > > Have tried various options including a specific eval() on the > ResponseText, setting the ContentType of the content etc without > success. It's hard to tell what the problem is. Could you show the relevant part of the code? -- 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
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 add a toString method
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 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 php global variable
global how .. that doesnt really explain much If you mean globaly accessible to javascript then you need to do something like foo=$bar"); ?> alert(foo); ... otherwise please be more specific Thanks Alex - Original Message - From: "marioosh" To: "Prototype & script.aculo.us" 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: > -- > > > > > > > > // want to be global, but how??? > $var = 'test'; > ?> > > > > > > > test1.js: > -- > Event.observe(document,'dom:loaded', function() { > new Ajax.Updater('debug','test2.php', { > onComplete: function() { > } > }); > }); > > > test2.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: '',anotherParam: 'blah',yetAnotherParam: 'Boing'}, onComplete: function(transport) { var data=transport.responseText;alert(data);} }); }); HTH Alex - Original Message - From: "Alex Mcauley" To: 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 > > $bar='bar'; > echo("foo=$bar"); > > ?> > > > alert(foo); > > ... > > otherwise please be more specific > > Thanks > Alex > > > - Original Message - > From: "marioosh" > To: "Prototype & script.aculo.us" > > 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: >> -- >> >> >> >> >> >> >> >> > // want to be global, but how??? >> $var = 'test'; >> ?> >> >> >> >> >> >> >> test1.js: >> -- >> Event.observe(document,'dom:loaded', function() { >> new Ajax.Updater('debug','test2.php', { >> onComplete: function() { >> } >> }); >> }); >> >> >> test2.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 > > $bar='bar'; > echo("foo=$bar"); > > ?> > 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: foo=" . json_encode($bar) . ""); ?> Which will give you something like: foo="bar" 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: '', } ?? On 3 Mar, 14:10, "Alex Mcauley" 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: '',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" To: 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 >> >> > $bar='bar'; >> echo("foo=$bar"); >> >> ?> >> > > > 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: > > $bar='bar'; > echo ("foo=" . json_encode($bar) . ""); > ?> > > Which will give you something like: > foo="bar" > > 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" To: "Prototype & script.aculo.us" 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" To: 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" To: 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, 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request, parameterrs, JSON, and ASP.NET - Invalid JSON primitive
The Object.toJSON(obiect) method can be used to serialize an object into JSON format. On Sep 10, 7:47 pm, Maulkye <[EMAIL PROTECTED]> wrote: > 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Request and text/javascript => syntax errors in javascript
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 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 and text/javascript => syntax errors in javascript
Hi again, Sorry for double-posting, but you might also consider loading the scripts a different way[1], since you're using a GET operation anyway. (You can encode the parameters in the URL using Hash.toQueryString[2].) The advantage to doing them that way is that if you add functions to the "global namespace" (the window object) and they're written in the standard "function xyz() { ... }" way, they'll get added to the namespace; with eval'd scripts, they won't; you have to write them like this: "xyz = function() { ... }", a trick that takes advantage of the Horror of Implicit Globals[3]. Using a script tag, you don't have to play those games. [1] http://proto-scripty.wikidot.com/prototype:how-to-load-scripts-dynamically [2] http://www.prototypejs.org/api/hash/toQueryString [3] http://blog.niftysnippets.org/2008/03/horror-of-implicit-globals.html 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 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 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 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 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=ProfileController&studentParamAttributes=" + 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 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 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 -~--~~~~--~~--~--~---