[Proto-Scripty] Re: AJAX Request: receive base64 encoded image in responseText

2012-08-16 Thread Victor


 Is response empty in network sniffer/web inspector? Or in javascript code?

  The response is already empty in web inspector.


Very bad
 

 You should check if it is actually written to HTTP response (maybe 
 response is already flushed).

 If I return some HTML in addition to my base64 string the HTML arrives in 
 response.

 
There is some problem in your server code. You should see returned base64 
string in response in Web Inspector/network sniffer.

the js code here: http://pastebin.com/Y9SFVxKq 


http://pastebin.com/CeREQhtd - cleaned up version, try this, you had extra 
space between parameter name and value in your code, also element 
manipulations were ineffective. 

-- 
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/-/BT1nuMIBfdcJ.
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: receive base64 encoded image in responseText

2012-08-15 Thread Victor


 I checked the response header and it's 
 Content-Type:
 text/html; charset=UTF-8. 
 Unfortunately I couldn't check the response because it's empty.


Is response empty in network sniffer/web inspector? Or in javascript code?
 

 Printing the return-part in my controller I got the correct base64-encoded 
 string.


You should check if it is actually written to HTTP response (maybe response 
is already flushed).
 

 I checked prototype api docs and it says, the response is going to be 
 eval'd
 before it shows up in browser.

 So what to do? Simply change the response content type? Is there any 
 base64-Type?


How are you processing response? Please show your code (here or in 
jsfiddle.net) or give a link to test site. Ajax.Response#responseText 
should be filled from XMLHttpRequest#responseText no matter which 
Content-Type is in response.

-- 
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/-/NHOK8gu2ZJ0J.
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: receive base64 encoded image in responseText

2012-08-15 Thread mabei
Dear Victor,

Am Mittwoch, 15. August 2012 11:47:25 UTC+2 schrieb Victor:

 I checked the response header and it's 
 Content-Type:
 text/html; charset=UTF-8. 
 Unfortunately I couldn't check the response because it's empty.


 Is response empty in network sniffer/web inspector? Or in javascript code?

  The response is already empty in web inspector.

  

 Printing the return-part in my controller I got the correct 
 base64-encoded string.


 You should check if it is actually written to HTTP response (maybe 
 response is already flushed).

If I return some HTML in addition to my base64 string the HTML arrives in 
response.

  

 I checked prototype api docs and it says, the response is going to be 
 eval'd
 before it shows up in browser.

 So what to do? Simply change the response content type? Is there any 
 base64-Type?


 How are you processing response? Please show your code (here or in 
 jsfiddle.net) or give a link to test site. Ajax.Response#responseText 
 should be filled from XMLHttpRequest#responseText no matter which 
 Content-Type is in response.

 You can find the js code here: http://pastebin.com/Y9SFVxKq 

-- 
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/-/eKImhJSKnNQJ.
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: receive base64 encoded image in responseText

2012-08-14 Thread mabei
Dear Victor,

thanks for your reply. I checked the response header and it's 
Content-Type:
text/html; charset=UTF-8. 
Unfortunately I couldn't check the response because it's empty. Printing 
the return-part in my controller
I got the correct base64-encoded string. I checked prototype api docs and 
it says, the response is going to be eval'd
before it shows up in browser.

So what to do? Simply change the response content type? Is there any 
base64-Type?

regards
mabei


Am Montag, 13. August 2012 14:00:46 UTC+2 schrieb Victor:

 I deliver a URL to my controller service via prototype ajax. This one is 
 fetching the image and returns
 the image base64_encoded.

 While observing the response I noticed just an empty result.


 How are you observing the response? Use network sniffer and/or Network 
 pane from Web Developer Tools in Chrome (Shift+Ctrl+I). Check content and 
 type of the response ('Content-Type' header).


-- 
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/-/CdW3S0_YQVsJ.
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: receive base64 encoded image in responseText

2012-08-14 Thread mabei
Additional info: when I print out the response to console I only receive:

*img src='data:image/jpeg;base64,' width='262'/*

So my base64-encoded string is cutted out. When calling 
my reloadurl directly in the browser the image shows up correctly.
Any further suggestions to this?
 
regards
mabei

Am Dienstag, 14. August 2012 09:24:51 UTC+2 schrieb mabei:

 Dear Victor,

 thanks for your reply. I checked the response header and it's 
 Content-Type:
 text/html; charset=UTF-8. 
 Unfortunately I couldn't check the response because it's empty. Printing 
 the return-part in my controller
 I got the correct base64-encoded string. I checked prototype api docs and 
 it says, the response is going to be eval'd
 before it shows up in browser.

 So what to do? Simply change the response content type? Is there any 
 base64-Type?

 regards
 mabei


 Am Montag, 13. August 2012 14:00:46 UTC+2 schrieb Victor:

 I deliver a URL to my controller service via prototype ajax. This one is 
 fetching the image and returns
 the image base64_encoded.

 While observing the response I noticed just an empty result.


 How are you observing the response? Use network sniffer and/or Network 
 pane from Web Developer Tools in Chrome (Shift+Ctrl+I). Check content and 
 type of the response ('Content-Type' header).



-- 
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/-/l2pg7_2S8tQJ.
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 no works on Chrome - decoding fails

2010-11-11 Thread T.J. Crowder
Hi,

It's T.J., not J.

 i want convert requestObject in JSON string and send to the server.

  var jsonRequest         =
 encodeURIComponent(JSON.stringify(requestObject));
 new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
             method:     'POST',
             requestHeaders: {Accept: 'application/json'},
             parameters:  jsonRequest,
             //...


Let's look at the code I gave you before AGAIN:

     var jsonRequest = ...;
     new Ajax.Request( // ...
         parameters: {json: jsonRequest}
         // ...
     });

As you can see, I used jsonRequest. I did that for a reason, so it
would fit in with your original code, which did this:

 var jsonRequest = JSON.stringify(requestObject);

So:

function sendMessage(baseUrl, idNickRcv, msg) {
var requestObject   = new Object();
requestObject.idNickRcv = idNickRcv;
requestObject.msg   = msg;

var jsonRequest = JSON.stringify(requestObject);

if ((idNickRcv)  (msg)) {
new Ajax.Request(baseUrl + 
'/usermsg/index/sendmessage', {
method: 'POST',
requestHeaders: {Accept: 'application/json'},
parameters: {json: jsonRequest}, // === CHANGE IS HERE
onSuccess:  function(transport, json) {
//use and handle foo response data
}
,
on500:  function(transport) {
//handle error, inform user
},
onComplete: parseSendMessage
});
}

// ...your code left off here

That tells Prototype to do any URI-encoding necessary for you (you
still have to stringify the object first, which is why I used
jsonRequest, not requestObject). It sends a nice, normal URL-encoded
request (technically an application/x-www-form-urlencoded POST) to
the server with a single form field, 'json', whose value is the URL-
encoded jsonRequest string.

Having done that, you ALSO have to change the server side to retrieve
and un-JSON that form field:

$request = $_POST[json];
$requestObject = Zend_Json::decode($request); // Or your $zendJson, 
 whatever that is

Now again, this is not the only way to do it. It's _possible_ to send
pure JSON without doing the form wrapper around it as I've done above
(in which case you probably wouldn't URL-encode at all, because you
wouldn't be sending URL-encoded data). You can send any content type
you like with a POST. If you're not sending data in the application/x-
www-form-urlencoded encoding, you have to specify what you're doing
by setting the Content-Type header (for pure JSON, it would be
application/json). You have to handle issues like ensuring there's a
carriage return every couple of hundred characters and such (because
of links in the chain that may handle HTTP poorly).

But whenever possible, I stick to sending standard forms, because
they're convenient and reliable across browsers and servers. Forms
(that is, POST requests with the content type application/x-www-form-
urlencoded) are well-tested, and well-supported by frameworks. Since
you appear to be in control of both the client and server sides of
what you're building, I'd probably stick with sending a form
containing a field with the JSON in it, rather than going through the
hassle of sending JSON without a form wrapper around it.

Hope this helps,

-- T.J.

On Nov 11, 12:49 am, fashionpeople fashionpeople.busin...@gmail.com
wrote:
 J. Crowder do not get me wrong, I thank you for the effort they put in
 helping others.

 i readed about your suggest to send data in this simple way:

     var jsonRequest = ...;
     new Ajax.Request( // ...
         parameters: {json: jsonRequest}
         // ...
     });

 but my question is, i have all based application such statements:

       var requestObject           = new Object();
       requestObject.idNickRcv = idNickRcv;
       requestObject.msg          = msg;

 i want convert requestObject in JSON string and send to the server.

  var jsonRequest         =
 encodeURIComponent(JSON.stringify(requestObject));
 new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
             method:     'POST',
             requestHeaders: {Accept: 'application/json'},
             parameters:  jsonRequest,
             //...

 In this way works only IE and FireWorks. Not on Chrome always decoding
 fails.
 you must use stringify? scriptaculous encodes them alone?

 Thank you

-- 
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 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-11 Thread fashionpeople
Hi T.J. Crowder,

 var jsonRequest = JSON.stringify(requestObject);

 new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
 method: 'POST',
 requestHeaders: {Accept: 'application/json'},
 parameters: {json: jsonRequest},
 // ...

In PHP:

 $request   = $this-getRequest();
 $json= $request-getParam(json);

// HERE decode fails with data sended from chrome
 $requestObject = $zendJson-decode($json, Zend_Json::TYPE_OBJECT);

With Chrome decoding fails too. Why? :\


On 11 Nov, 03:47, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

 It's T.J., not J.

  i want convert requestObject in JSON string and send to the server.

   var jsonRequest         =
  encodeURIComponent(JSON.stringify(requestObject));
  new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
              method:     'POST',
              requestHeaders: {Accept: 'application/json'},
              parameters:  jsonRequest,
              //...

 Let's look at the code I gave you before AGAIN:

      var jsonRequest = ...;
      new Ajax.Request( // ...
          parameters: {json: jsonRequest}
          // ...
      });

 As you can see, I used jsonRequest. I did that for a reason, so it
 would fit in with your original code, which did this:

  var jsonRequest         = JSON.stringify(requestObject);

 So:

 function sendMessage(baseUrl, idNickRcv, msg) {
         var requestObject       = new Object();
         requestObject.idNickRcv = idNickRcv;
         requestObject.msg       = msg;

         var jsonRequest         = JSON.stringify(requestObject);

         if ((idNickRcv)  (msg)) {
                         new Ajax.Request(baseUrl + 
 '/usermsg/index/sendmessage', {
                         method:     'POST',
                         requestHeaders: {Accept: 'application/json'},
                         parameters: {json: jsonRequest}, // === CHANGE IS 
 HERE
                         onSuccess:  function(transport, json) {
                                 //use and handle foo response data
                         }
                         ,
                         on500:      function(transport) {
                                 //handle error, inform user
                         },
                         onComplete: parseSendMessage
                 });
         }

     // ...your code left off here

 That tells Prototype to do any URI-encoding necessary for you (you
 still have to stringify the object first, which is why I used
 jsonRequest, not requestObject). It sends a nice, normal URL-encoded
 request (technically an application/x-www-form-urlencoded POST) to
 the server with a single form field, 'json', whose value is the URL-
 encoded jsonRequest string.

 Having done that, you ALSO have to change the server side to retrieve
 and un-JSON that form field:

     $request = $_POST[json];
     $requestObject = Zend_Json::decode($request); // Or your $zendJson, 
  whatever that is

 Now again, this is not the only way to do it. It's _possible_ to send
 pure JSON without doing the form wrapper around it as I've done above
 (in which case you probably wouldn't URL-encode at all, because you
 wouldn't be sending URL-encoded data). You can send any content type
 you like with a POST. If you're not sending data in the application/x-
 www-form-urlencoded encoding, you have to specify what you're doing
 by setting the Content-Type header (for pure JSON, it would be
 application/json). You have to handle issues like ensuring there's a
 carriage return every couple of hundred characters and such (because
 of links in the chain that may handle HTTP poorly).

 But whenever possible, I stick to sending standard forms, because
 they're convenient and reliable across browsers and servers. Forms
 (that is, POST requests with the content type application/x-www-form-
 urlencoded) are well-tested, and well-supported by frameworks. Since
 you appear to be in control of both the client and server sides of
 what you're building, I'd probably stick with sending a form
 containing a field with the JSON in it, rather than going through the
 hassle of sending JSON without a form wrapper around it.

 Hope this helps,

 -- T.J.

 On Nov 11, 12:49 am, fashionpeople fashionpeople.busin...@gmail.com
 wrote:







  J. Crowder do not get me wrong, I thank you for the effort they put in
  helping others.

  i readed about your suggest to send data in this simple way:

      var jsonRequest = ...;
      new Ajax.Request( // ...
          parameters: {json: jsonRequest}
          // ...
      });

  but my question is, i have all based application such statements:

        var requestObject           = new Object();
        requestObject.idNickRcv = idNickRcv;
        requestObject.msg          = msg;

  i want convert requestObject in JSON string and send to the server.

   var jsonRequest         =
  encodeURIComponent(JSON.stringify(requestObject));
  new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {

Re: [Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-11 Thread Walter Lee Davis


On Nov 11, 2010, at 8:20 AM, fashionpeople wrote:


Hi T.J. Crowder,

var jsonRequest = JSON.stringify(requestObject);

new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
method: 'POST',
requestHeaders: {Accept: 'application/json'},
parameters: {json: jsonRequest},
// ...

In PHP:

$request   = $this-getRequest();
$json= $request-getParam(json);

// HERE decode fails with data sended from chrome
$requestObject = $zendJson-decode($json, Zend_Json::TYPE_OBJECT);

With Chrome decoding fails too. Why? :\



Can you print out the raw value of your $json string after the  
getParam call? Then echo a few paragraph returns and also print the  
raw value of $_POST['json'].


You have two different black boxes here -- getParam() and $zendJson- 
decode(). Either one of these may be helping you by decoding some  
part of the variable posted by Prototype. You may be double-decoding  
something, or missing the decode on something else. Try printing the  
raw text to the screen each time and see what and where the value  
changes in your server-side.


It's unlikely that encodeURIComponent is different between two  
browsers. There may indeed be some other part of Prototype that is  
over-correcting some encoding on the browser side, based on a mis- 
reading of the user agent or some other variable.


But I would button down the server side first, and make sure that you  
are getting the very same raw data in and that your conversions are  
proceeding in a normal fashion within the PHP domain.


If two browsers send two different raw POST bodies, then you're right  
-- the issue is within Prototype, or maybe within the browser and  
Prototype isn't spackling over it the way it usually does.


You may also have found a difference of opinion between PHP JSON and  
JS JSON -- these do exist and they are very annoying and require hunt- 
and-peck application of addslashes() and stripslashes(). Which reminds  
me -- do look at the current value of magic_quotes_gpc, both on your  
server and within your application. That's another snake-pit I have  
had to cross with JSON on PHP.


Walter



On 11 Nov, 03:47, T.J. Crowder t...@crowdersoftware.com wrote:

Hi,

It's T.J., not J.


i want convert requestObject in JSON string and send to the server.



 var jsonRequest =
encodeURIComponent(JSON.stringify(requestObject));
new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
method: 'POST',
requestHeaders: {Accept: 'application/json'},
parameters:  jsonRequest,
//...


Let's look at the code I gave you before AGAIN:


var jsonRequest = ...;
new Ajax.Request( // ...
parameters: {json: jsonRequest}
// ...
});


As you can see, I used jsonRequest. I did that for a reason, so it
would fit in with your original code, which did this:


var jsonRequest = JSON.stringify(requestObject);


So:

function sendMessage(baseUrl, idNickRcv, msg) {
var requestObject   = new Object();
requestObject.idNickRcv = idNickRcv;
requestObject.msg   = msg;

var jsonRequest = JSON.stringify(requestObject);

if ((idNickRcv)  (msg)) {
new Ajax.Request(baseUrl + '/usermsg/index/ 
sendmessage', {

method: 'POST',
requestHeaders: {Accept: 'application/json'},
parameters: {json: jsonRequest}, // ===  
CHANGE IS HERE

onSuccess:  function(transport, json) {
//use and handle foo response data
}
,
on500:  function(transport) {
//handle error, inform user
},
onComplete: parseSendMessage
});
}

// ...your code left off here

That tells Prototype to do any URI-encoding necessary for you (you
still have to stringify the object first, which is why I used
jsonRequest, not requestObject). It sends a nice, normal URL-encoded
request (technically an application/x-www-form-urlencoded POST) to
the server with a single form field, 'json', whose value is the URL-
encoded jsonRequest string.

Having done that, you ALSO have to change the server side to retrieve
and un-JSON that form field:


   $request = $_POST[json];
   $requestObject = Zend_Json::decode($request); // Or your  
$zendJson, whatever that is


Now again, this is not the only way to do it. It's _possible_ to send
pure JSON without doing the form wrapper around it as I've done above
(in which case you probably wouldn't URL-encode at all, because you
wouldn't be sending URL-encoded data). You can send any content type
you like with a POST. If you're not sending data in the  
application/x-

www-form-urlencoded encoding, you have to specify what you're doing
by setting the Content-Type 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-11 Thread fashionpeople
Hi T.J. Crowder,

Now works with your suggests. Thanks a lot.
The ajax request look like doesn't work, because callback parse, it
did call another ajax request not fixed with your suggets.

Thanks.

On 11 Nov, 15:43, Walter Lee Davis wa...@wdstudio.com wrote:
 On Nov 11, 2010, at 8:20 AM, fashionpeople wrote:









  Hi T.J. Crowder,

  var jsonRequest         = JSON.stringify(requestObject);

  new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
  method:     'POST',
  requestHeaders: {Accept: 'application/json'},
  parameters: {json: jsonRequest},
  // ...

  In PHP:

  $request           = $this-getRequest();
  $json                = $request-getParam(json);

  // HERE decode fails with data sended from chrome
  $requestObject = $zendJson-decode($json, Zend_Json::TYPE_OBJECT);

  With Chrome decoding fails too. Why? :\

 Can you print out the raw value of your $json string after the  
 getParam call? Then echo a few paragraph returns and also print the  
 raw value of $_POST['json'].

 You have two different black boxes here -- getParam() and $zendJson-
  decode(). Either one of these may be helping you by decoding some  
 part of the variable posted by Prototype. You may be double-decoding  
 something, or missing the decode on something else. Try printing the  
 raw text to the screen each time and see what and where the value  
 changes in your server-side.

 It's unlikely that encodeURIComponent is different between two  
 browsers. There may indeed be some other part of Prototype that is  
 over-correcting some encoding on the browser side, based on a mis-
 reading of the user agent or some other variable.

 But I would button down the server side first, and make sure that you  
 are getting the very same raw data in and that your conversions are  
 proceeding in a normal fashion within the PHP domain.

 If two browsers send two different raw POST bodies, then you're right  
 -- the issue is within Prototype, or maybe within the browser and  
 Prototype isn't spackling over it the way it usually does.

 You may also have found a difference of opinion between PHP JSON and  
 JS JSON -- these do exist and they are very annoying and require hunt-
 and-peck application of addslashes() and stripslashes(). Which reminds  
 me -- do look at the current value of magic_quotes_gpc, both on your  
 server and within your application. That's another snake-pit I have  
 had to cross with JSON on PHP.

 Walter









  On 11 Nov, 03:47, T.J. Crowder t...@crowdersoftware.com wrote:
  Hi,

  It's T.J., not J.

  i want convert requestObject in JSON string and send to the server.

   var jsonRequest         =
  encodeURIComponent(JSON.stringify(requestObject));
  new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
              method:     'POST',
              requestHeaders: {Accept: 'application/json'},
              parameters:  jsonRequest,
              //...

  Let's look at the code I gave you before AGAIN:

      var jsonRequest = ...;
      new Ajax.Request( // ...
          parameters: {json: jsonRequest}
          // ...
      });

  As you can see, I used jsonRequest. I did that for a reason, so it
  would fit in with your original code, which did this:

  var jsonRequest         = JSON.stringify(requestObject);

  So:

  function sendMessage(baseUrl, idNickRcv, msg) {
          var requestObject       = new Object();
          requestObject.idNickRcv = idNickRcv;
          requestObject.msg       = msg;

          var jsonRequest         = JSON.stringify(requestObject);

          if ((idNickRcv)  (msg)) {
                          new Ajax.Request(baseUrl + '/usermsg/index/
  sendmessage', {
                          method:     'POST',
                          requestHeaders: {Accept: 'application/json'},
                          parameters: {json: jsonRequest}, // ===  
  CHANGE IS HERE
                          onSuccess:  function(transport, json) {
                                  //use and handle foo response data
                          }
                          ,
                          on500:      function(transport) {
                                  //handle error, inform user
                          },
                          onComplete: parseSendMessage
                  });
          }

      // ...your code left off here

  That tells Prototype to do any URI-encoding necessary for you (you
  still have to stringify the object first, which is why I used
  jsonRequest, not requestObject). It sends a nice, normal URL-encoded
  request (technically an application/x-www-form-urlencoded POST) to
  the server with a single form field, 'json', whose value is the URL-
  encoded jsonRequest string.

  Having done that, you ALSO have to change the server side to retrieve
  and un-JSON that form field:

     $request = $_POST[json];
     $requestObject = Zend_Json::decode($request); // Or your  
  $zendJson, whatever that is

  Now again, this is not the only way 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-10 Thread T.J. Crowder
Hi,

 I tried use fixedEncodeURI like suggest in your links.

I've never even heard of fixedEncodeURI.

People are taking the time to help you here, it's worth taking the
time to carefully *read* what people have written and try the things
they suggest (or not, of course, it's up to you).

This is what I've suggested that you haven't, as far as I can tell,
tried:

On Nov 8, 9:42 pm, T.J. Crowder t...@crowdersoftware.com wrote:

 The most reliable way to send parameters that I know is to send them
 URL-encoded, and to decode them as URL-encoded data. In Prototype, the
 easiest way to do that is to supply a plain object to the Ajax.Request
 method (which Prototype will correctly encode for you):

     var jsonRequest = ...;
     new Ajax.Request( // ...
         parameters: {json: jsonRequest}
         // ...
     });

 ...and then retrieve the value just as you would any other value:

     $request = $_POST[json];
     $requestObject = Zend_Json::decode($request); // Or your
 $zendJson, whatever that is

Good luck with it,

-- T.J.

On Nov 9, 11:37 pm, fashionpeople fashionpeople.busin...@gmail.com
wrote:
 I tried use fixedEncodeURI like suggest in your links.

 But doesn't work.
 I didn't understand the problem.

 On 9 Nov, 17:25, T.J. Crowder t...@crowdersoftware.com wrote:







  Hi,

   I replaced escape with encodeURI. But decoding fails again.

  Well, did you try actually doing what I suggested?

  -- T.J.

  On Nov 9, 4:07 pm, fashionpeople fashionpeople.busin...@gmail.com
  wrote:

   Hi,

   I replaced escape with encodeURI. But decoding fails again.

      function sendMessage(baseUrl, idNickRcv, msg) {

         var requestObject       = new Object();
         requestObject.idNickRcv = idNickRcv;
         requestObject.msg       = msg;

         var jsonRequest         = JSON.stringify(requestObject);

         if ((idNickRcv)  (msg)) {

            new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
               method:     'POST',
               requestHeaders:{ Accept:'application/json' },
               parameters: encodeURI(jsonRequest),

                            onSuccess:
                             function(transport, json) {
                             //use and handle foo response data
                            }
                            ,
                            on500:
                             function(transport) {
                             //handle error, inform user
                             },
                            onComplete: parseSendMessage

                  });

         }

   php:

         $request       = rawurldecode($this-getRequest()-

   getRawBody());

   // HERE DECODING FAILS AND EXECUTION IS INTERRUPTED.
         $requestObject = $zendJson-decode($request,
   Zend_Json::TYPE_OBJECT);
         $msg           = $requestObject-msg;
         $idNickRcv     = $requestObject-idNickRcv;

   On 8 Nov, 23:11, Walter Lee Davis wa...@wdstudio.com wrote:

Right. The best low-level way to translate JS to PHP and back again is  
using encodeURI or uncodeURIComponent on your JS side, and  
rawurldecode() or rawurlencode() on the PHP side. They are  
functionally identical, as long as you have set your PHP side to use  
UTF-8 as its default charset.

Walter

On Nov 8, 2010, at 4:42 PM, T.J. Crowder wrote:

 Hi,

 I don't know that it's the problem because I'm not a PHP person, but
 you're using the `escape` function to encode your parameters, and then
 decoding them with a PHP function called `urldecode`. JavaScript's
 `escape` function does _not_ URL-encode things, it does something
 similar but different and is almost certainly not what you want. I'm
 surprised it's working with other browsers, frankly, but perhaps
 that's my lack of PHP knowledge.

 The most reliable way to send parameters that I know is to send them
 URL-encoded, and to decode them as URL-encoded data. In Prototype, the
 easiest way to do that is to supply a plain object to the Ajax.Request
 method (which Prototype will correctly encode for you):

    var jsonRequest = ...;
    new Ajax.Request( // ...
        parameters: {json: jsonRequest}
        // ...
    });

 ...and then retrieve the value just as you would any other value:

    $request = $_POST[json];
    $requestObject = Zend_Json::decode($request); // Or your
 $zendJson, whatever that is

 But again, I'm not a PHP guy and could easily be missing something
 important here.

 FWIW,
 --
 T.J. Crowder
 Independent Software Engineer
 tj / crowder software / com
 www / crowder software / com

 On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
 wrote:
 Hi,

 this is my ajax request that works perfectly on IE and FIREFOX, but
 not in CHROME!

    function sendMessage(baseUrl, idNickRcv, msg) {

       var requestObject       = new 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-10 Thread Eric
It may be helping if you could trace and post here the following
things :
From Javascript:
- requestObject
- JSON.stringify(requestObject)
From PHP:
- $this-getRequest()-getRawBody();
- rawurldecode($this-getRequest()-getRawBody());

Also, why do you need to use JSON.stringify thing when, as T.J. told
you (twice) prototype is designed to take care of it for you.

Eric

On 10 nov, 00:37, fashionpeople fashionpeople.busin...@gmail.com
wrote:
 I tried use fixedEncodeURI like suggest in your links.

 But doesn't work.
 I didn't understand the problem.

 On 9 Nov, 17:25, T.J. Crowder t...@crowdersoftware.com wrote:

  Hi,

   I replaced escape with encodeURI. But decoding fails again.

  Well, did you try actually doing what I suggested?

  -- T.J.

  On Nov 9, 4:07 pm, fashionpeople fashionpeople.busin...@gmail.com
  wrote:

   Hi,

   I replaced escape with encodeURI. But decoding fails again.

      function sendMessage(baseUrl, idNickRcv, msg) {

         var requestObject       = new Object();
         requestObject.idNickRcv = idNickRcv;
         requestObject.msg       = msg;

         var jsonRequest         = JSON.stringify(requestObject);

         if ((idNickRcv)  (msg)) {

            new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
               method:     'POST',
               requestHeaders:{ Accept:'application/json' },
               parameters: encodeURI(jsonRequest),

                            onSuccess:
                             function(transport, json) {
                             //use and handle foo response data
                            }
                            ,
                            on500:
                             function(transport) {
                             //handle error, inform user
                             },
                            onComplete: parseSendMessage

                  });

         }

   php:

         $request       = rawurldecode($this-getRequest()-

   getRawBody());

   // HERE DECODING FAILS AND EXECUTION IS INTERRUPTED.
         $requestObject = $zendJson-decode($request,
   Zend_Json::TYPE_OBJECT);
         $msg           = $requestObject-msg;
         $idNickRcv     = $requestObject-idNickRcv;

   On 8 Nov, 23:11, Walter Lee Davis wa...@wdstudio.com wrote:

Right. The best low-level way to translate JS to PHP and back again is  
using encodeURI or uncodeURIComponent on your JS side, and  
rawurldecode() or rawurlencode() on the PHP side. They are  
functionally identical, as long as you have set your PHP side to use  
UTF-8 as its default charset.

Walter

On Nov 8, 2010, at 4:42 PM, T.J. Crowder wrote:

 Hi,

 I don't know that it's the problem because I'm not a PHP person, but
 you're using the `escape` function to encode your parameters, and then
 decoding them with a PHP function called `urldecode`. JavaScript's
 `escape` function does _not_ URL-encode things, it does something
 similar but different and is almost certainly not what you want. I'm
 surprised it's working with other browsers, frankly, but perhaps
 that's my lack of PHP knowledge.

 The most reliable way to send parameters that I know is to send them
 URL-encoded, and to decode them as URL-encoded data. In Prototype, the
 easiest way to do that is to supply a plain object to the Ajax.Request
 method (which Prototype will correctly encode for you):

    var jsonRequest = ...;
    new Ajax.Request( // ...
        parameters: {json: jsonRequest}
        // ...
    });

 ...and then retrieve the value just as you would any other value:

    $request = $_POST[json];
    $requestObject = Zend_Json::decode($request); // Or your
 $zendJson, whatever that is

 But again, I'm not a PHP guy and could easily be missing something
 important here.

 FWIW,
 --
 T.J. Crowder
 Independent Software Engineer
 tj / crowder software / com
 www / crowder software / com

 On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
 wrote:
 Hi,

 this is my ajax request that works perfectly on IE and FIREFOX, but
 not in CHROME!

    function sendMessage(baseUrl, idNickRcv, msg) {

       var requestObject       = new Object();
       requestObject.idNickRcv = idNickRcv;
       requestObject.msg       = msg;

       var jsonRequest         = JSON.stringify(requestObject);

       if ((idNickRcv)  (msg)) {

          new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
             method:     'POST',
             requestHeaders:{ Accept:'application/json' },
             parameters: escape(jsonRequest),

                          onSuccess:
                           function(transport, json) {
                           //use and handle foo response data
                          }
                          ,
                    

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-10 Thread fashionpeople
J. Crowder do not get me wrong, I thank you for the effort they put in
helping others.

i readed about your suggest to send data in this simple way:

var jsonRequest = ...;
new Ajax.Request( // ...
parameters: {json: jsonRequest}
// ...
});

but my question is, i have all based application such statements:

  var requestObject   = new Object();
  requestObject.idNickRcv = idNickRcv;
  requestObject.msg  = msg;

i want convert requestObject in JSON string and send to the server.

 var jsonRequest =
encodeURIComponent(JSON.stringify(requestObject));
new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
method: 'POST',
requestHeaders: {Accept: 'application/json'},
parameters:  jsonRequest,
//...

In this way works only IE and FireWorks. Not on Chrome always decoding
fails.
you must use stringify? scriptaculous encodes them alone?

Thank you

-- 
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 no works on Chrome - decoding fails

2010-11-09 Thread fashionpeople
Hi,

I replaced escape with encodeURI. But decoding fails again.

   function sendMessage(baseUrl, idNickRcv, msg) {

  var requestObject   = new Object();
  requestObject.idNickRcv = idNickRcv;
  requestObject.msg   = msg;

  var jsonRequest = JSON.stringify(requestObject);

  if ((idNickRcv)  (msg)) {

 new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
method: 'POST',
requestHeaders:{ Accept:'application/json' },
parameters: encodeURI(jsonRequest),

 onSuccess:
  function(transport, json) {
  //use and handle foo response data
 }
 ,
 on500:
  function(transport) {
  //handle error, inform user
  },
 onComplete: parseSendMessage

   });


  }

php:

  $request   = rawurldecode($this-getRequest()-
getRawBody());

// HERE DECODING FAILS AND EXECUTION IS INTERRUPTED.
  $requestObject = $zendJson-decode($request,
Zend_Json::TYPE_OBJECT);
  $msg   = $requestObject-msg;
  $idNickRcv = $requestObject-idNickRcv;

On 8 Nov, 23:11, Walter Lee Davis wa...@wdstudio.com wrote:
 Right. The best low-level way to translate JS to PHP and back again is  
 using encodeURI or uncodeURIComponent on your JS side, and  
 rawurldecode() or rawurlencode() on the PHP side. They are  
 functionally identical, as long as you have set your PHP side to use  
 UTF-8 as its default charset.

 Walter

 On Nov 8, 2010, at 4:42 PM, T.J. Crowder wrote:







  Hi,

  I don't know that it's the problem because I'm not a PHP person, but
  you're using the `escape` function to encode your parameters, and then
  decoding them with a PHP function called `urldecode`. JavaScript's
  `escape` function does _not_ URL-encode things, it does something
  similar but different and is almost certainly not what you want. I'm
  surprised it's working with other browsers, frankly, but perhaps
  that's my lack of PHP knowledge.

  The most reliable way to send parameters that I know is to send them
  URL-encoded, and to decode them as URL-encoded data. In Prototype, the
  easiest way to do that is to supply a plain object to the Ajax.Request
  method (which Prototype will correctly encode for you):

     var jsonRequest = ...;
     new Ajax.Request( // ...
         parameters: {json: jsonRequest}
         // ...
     });

  ...and then retrieve the value just as you would any other value:

     $request = $_POST[json];
     $requestObject = Zend_Json::decode($request); // Or your
  $zendJson, whatever that is

  But again, I'm not a PHP guy and could easily be missing something
  important here.

  FWIW,
  --
  T.J. Crowder
  Independent Software Engineer
  tj / crowder software / com
  www / crowder software / com

  On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
  wrote:
  Hi,

  this is my ajax request that works perfectly on IE and FIREFOX, but
  not in CHROME!

     function sendMessage(baseUrl, idNickRcv, msg) {

        var requestObject       = new Object();
        requestObject.idNickRcv = idNickRcv;
        requestObject.msg       = msg;

        var jsonRequest         = JSON.stringify(requestObject);

        if ((idNickRcv)  (msg)) {

           new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
              method:     'POST',
              requestHeaders:{ Accept:'application/json' },
              parameters: escape(jsonRequest),

                           onSuccess:
                            function(transport, json) {
                            //use and handle foo response data
                           }
                           ,
                           on500:
                            function(transport) {
                            //handle error, inform user
                            },
                           onComplete: parseSendMessage

                 });

        }

  the problem is in action side server.
  there is this PHP / ZEND FRAMEWORK code:

  

        $request          = urldecode($this-getRequest()-
  getRawBody());

        $requestObject = $zendJson-decode($request,
  Zend_Json::TYPE_OBJECT);

  

  Json decoding fails with Syntax Error, for this reason Ajax request  
  no
  works and is interrupted.
  Chrome send a bad json string!

  Any suggests?

  --
  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 
  athttp://groups.google.com/group/prototype-scriptaculous?hl=en
  .

-- 
You received this 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-09 Thread T.J. Crowder
Hi,

 I replaced escape with encodeURI. But decoding fails again.

Well, did you try actually doing what I suggested?

-- T.J.

On Nov 9, 4:07 pm, fashionpeople fashionpeople.busin...@gmail.com
wrote:
 Hi,

 I replaced escape with encodeURI. But decoding fails again.

    function sendMessage(baseUrl, idNickRcv, msg) {

       var requestObject       = new Object();
       requestObject.idNickRcv = idNickRcv;
       requestObject.msg       = msg;

       var jsonRequest         = JSON.stringify(requestObject);

       if ((idNickRcv)  (msg)) {

          new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
             method:     'POST',
             requestHeaders:{ Accept:'application/json' },
             parameters: encodeURI(jsonRequest),

                          onSuccess:
                           function(transport, json) {
                           //use and handle foo response data
                          }
                          ,
                          on500:
                           function(transport) {
                           //handle error, inform user
                           },
                          onComplete: parseSendMessage

                });

       }

 php:

       $request       = rawurldecode($this-getRequest()-

 getRawBody());

 // HERE DECODING FAILS AND EXECUTION IS INTERRUPTED.
       $requestObject = $zendJson-decode($request,
 Zend_Json::TYPE_OBJECT);
       $msg           = $requestObject-msg;
       $idNickRcv     = $requestObject-idNickRcv;

 On 8 Nov, 23:11, Walter Lee Davis wa...@wdstudio.com wrote:







  Right. The best low-level way to translate JS to PHP and back again is  
  using encodeURI or uncodeURIComponent on your JS side, and  
  rawurldecode() or rawurlencode() on the PHP side. They are  
  functionally identical, as long as you have set your PHP side to use  
  UTF-8 as its default charset.

  Walter

  On Nov 8, 2010, at 4:42 PM, T.J. Crowder wrote:

   Hi,

   I don't know that it's the problem because I'm not a PHP person, but
   you're using the `escape` function to encode your parameters, and then
   decoding them with a PHP function called `urldecode`. JavaScript's
   `escape` function does _not_ URL-encode things, it does something
   similar but different and is almost certainly not what you want. I'm
   surprised it's working with other browsers, frankly, but perhaps
   that's my lack of PHP knowledge.

   The most reliable way to send parameters that I know is to send them
   URL-encoded, and to decode them as URL-encoded data. In Prototype, the
   easiest way to do that is to supply a plain object to the Ajax.Request
   method (which Prototype will correctly encode for you):

      var jsonRequest = ...;
      new Ajax.Request( // ...
          parameters: {json: jsonRequest}
          // ...
      });

   ...and then retrieve the value just as you would any other value:

      $request = $_POST[json];
      $requestObject = Zend_Json::decode($request); // Or your
   $zendJson, whatever that is

   But again, I'm not a PHP guy and could easily be missing something
   important here.

   FWIW,
   --
   T.J. Crowder
   Independent Software Engineer
   tj / crowder software / com
   www / crowder software / com

   On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
   wrote:
   Hi,

   this is my ajax request that works perfectly on IE and FIREFOX, but
   not in CHROME!

      function sendMessage(baseUrl, idNickRcv, msg) {

         var requestObject       = new Object();
         requestObject.idNickRcv = idNickRcv;
         requestObject.msg       = msg;

         var jsonRequest         = JSON.stringify(requestObject);

         if ((idNickRcv)  (msg)) {

            new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
               method:     'POST',
               requestHeaders:{ Accept:'application/json' },
               parameters: escape(jsonRequest),

                            onSuccess:
                             function(transport, json) {
                             //use and handle foo response data
                            }
                            ,
                            on500:
                             function(transport) {
                             //handle error, inform user
                             },
                            onComplete: parseSendMessage

                  });

         }

   the problem is in action side server.
   there is this PHP / ZEND FRAMEWORK code:

   

         $request          = urldecode($this-getRequest()-
   getRawBody());

         $requestObject = $zendJson-decode($request,
   Zend_Json::TYPE_OBJECT);

   

   Json decoding fails with Syntax Error, for this reason Ajax request  
   no
   works and is interrupted.
   Chrome send a bad json string!

   Any suggests?

   --
   You received this message because you are subscribed to the Google  
   Groups Prototype  script.aculo.us group.
   To post 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-09 Thread fashionpeople
Hi,

I replaced escape with encodeURI. But decoding fails again.

   function sendMessage(baseUrl, idNickRcv, msg) {

  var requestObject   = new Object();
  requestObject.idNickRcv = idNickRcv;
  requestObject.msg   = msg;

  var jsonRequest = JSON.stringify(requestObject);

  if ((idNickRcv)  (msg)) {

 new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
method: 'POST',
requestHeaders:{ Accept:'application/json' },
parameters: encodeURI(jsonRequest),

 onSuccess:
  function(transport, json) {
  //use and handle foo response data
 }
 ,
 on500:
  function(transport) {
  //handle error, inform user
  },
 onComplete: parseSendMessage

   });


  }

php:

  $request   = rawurldecode($this-getRequest()-
getRawBody());

// HERE DECODING FAILS AND EXECUTION IS INTERRUPTED.
  $requestObject = $zendJson-decode($request,
Zend_Json::TYPE_OBJECT);
  $msg   = $requestObject-msg;
  $idNickRcv = $requestObject-idNickRcv;

On 8 Nov, 23:11, Walter Lee Davis wa...@wdstudio.com wrote:
 Right. The best low-level way to translate JS to PHP and back again is  
 using encodeURI or uncodeURIComponent on your JS side, and  
 rawurldecode() or rawurlencode() on the PHP side. They are  
 functionally identical, as long as you have set your PHP side to use  
 UTF-8 as its default charset.

 Walter

 On Nov 8, 2010, at 4:42 PM, T.J. Crowder wrote:







  Hi,

  I don't know that it's the problem because I'm not a PHP person, but
  you're using the `escape` function to encode your parameters, and then
  decoding them with a PHP function called `urldecode`. JavaScript's
  `escape` function does _not_ URL-encode things, it does something
  similar but different and is almost certainly not what you want. I'm
  surprised it's working with other browsers, frankly, but perhaps
  that's my lack of PHP knowledge.

  The most reliable way to send parameters that I know is to send them
  URL-encoded, and to decode them as URL-encoded data. In Prototype, the
  easiest way to do that is to supply a plain object to the Ajax.Request
  method (which Prototype will correctly encode for you):

     var jsonRequest = ...;
     new Ajax.Request( // ...
         parameters: {json: jsonRequest}
         // ...
     });

  ...and then retrieve the value just as you would any other value:

     $request = $_POST[json];
     $requestObject = Zend_Json::decode($request); // Or your
  $zendJson, whatever that is

  But again, I'm not a PHP guy and could easily be missing something
  important here.

  FWIW,
  --
  T.J. Crowder
  Independent Software Engineer
  tj / crowder software / com
  www / crowder software / com

  On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
  wrote:
  Hi,

  this is my ajax request that works perfectly on IE and FIREFOX, but
  not in CHROME!

     function sendMessage(baseUrl, idNickRcv, msg) {

        var requestObject       = new Object();
        requestObject.idNickRcv = idNickRcv;
        requestObject.msg       = msg;

        var jsonRequest         = JSON.stringify(requestObject);

        if ((idNickRcv)  (msg)) {

           new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
              method:     'POST',
              requestHeaders:{ Accept:'application/json' },
              parameters: escape(jsonRequest),

                           onSuccess:
                            function(transport, json) {
                            //use and handle foo response data
                           }
                           ,
                           on500:
                            function(transport) {
                            //handle error, inform user
                            },
                           onComplete: parseSendMessage

                 });

        }

  the problem is in action side server.
  there is this PHP / ZEND FRAMEWORK code:

  

        $request          = urldecode($this-getRequest()-
  getRawBody());

        $requestObject = $zendJson-decode($request,
  Zend_Json::TYPE_OBJECT);

  

  Json decoding fails with Syntax Error, for this reason Ajax request  
  no
  works and is interrupted.
  Chrome send a bad json string!

  Any suggests?

  --
  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 
  athttp://groups.google.com/group/prototype-scriptaculous?hl=en
  .

-- 
You received this 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-09 Thread fashionpeople
I tried use fixedEncodeURI like suggest in your links.

But doesn't work.
I didn't understand the problem.

On 9 Nov, 17:25, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

  I replaced escape with encodeURI. But decoding fails again.

 Well, did you try actually doing what I suggested?

 -- T.J.

 On Nov 9, 4:07 pm, fashionpeople fashionpeople.busin...@gmail.com
 wrote:







  Hi,

  I replaced escape with encodeURI. But decoding fails again.

     function sendMessage(baseUrl, idNickRcv, msg) {

        var requestObject       = new Object();
        requestObject.idNickRcv = idNickRcv;
        requestObject.msg       = msg;

        var jsonRequest         = JSON.stringify(requestObject);

        if ((idNickRcv)  (msg)) {

           new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
              method:     'POST',
              requestHeaders:{ Accept:'application/json' },
              parameters: encodeURI(jsonRequest),

                           onSuccess:
                            function(transport, json) {
                            //use and handle foo response data
                           }
                           ,
                           on500:
                            function(transport) {
                            //handle error, inform user
                            },
                           onComplete: parseSendMessage

                 });

        }

  php:

        $request       = rawurldecode($this-getRequest()-

  getRawBody());

  // HERE DECODING FAILS AND EXECUTION IS INTERRUPTED.
        $requestObject = $zendJson-decode($request,
  Zend_Json::TYPE_OBJECT);
        $msg           = $requestObject-msg;
        $idNickRcv     = $requestObject-idNickRcv;

  On 8 Nov, 23:11, Walter Lee Davis wa...@wdstudio.com wrote:

   Right. The best low-level way to translate JS to PHP and back again is  
   using encodeURI or uncodeURIComponent on your JS side, and  
   rawurldecode() or rawurlencode() on the PHP side. They are  
   functionally identical, as long as you have set your PHP side to use  
   UTF-8 as its default charset.

   Walter

   On Nov 8, 2010, at 4:42 PM, T.J. Crowder wrote:

Hi,

I don't know that it's the problem because I'm not a PHP person, but
you're using the `escape` function to encode your parameters, and then
decoding them with a PHP function called `urldecode`. JavaScript's
`escape` function does _not_ URL-encode things, it does something
similar but different and is almost certainly not what you want. I'm
surprised it's working with other browsers, frankly, but perhaps
that's my lack of PHP knowledge.

The most reliable way to send parameters that I know is to send them
URL-encoded, and to decode them as URL-encoded data. In Prototype, the
easiest way to do that is to supply a plain object to the Ajax.Request
method (which Prototype will correctly encode for you):

   var jsonRequest = ...;
   new Ajax.Request( // ...
       parameters: {json: jsonRequest}
       // ...
   });

...and then retrieve the value just as you would any other value:

   $request = $_POST[json];
   $requestObject = Zend_Json::decode($request); // Or your
$zendJson, whatever that is

But again, I'm not a PHP guy and could easily be missing something
important here.

FWIW,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
wrote:
Hi,

this is my ajax request that works perfectly on IE and FIREFOX, but
not in CHROME!

   function sendMessage(baseUrl, idNickRcv, msg) {

      var requestObject       = new Object();
      requestObject.idNickRcv = idNickRcv;
      requestObject.msg       = msg;

      var jsonRequest         = JSON.stringify(requestObject);

      if ((idNickRcv)  (msg)) {

         new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
            method:     'POST',
            requestHeaders:{ Accept:'application/json' },
            parameters: escape(jsonRequest),

                         onSuccess:
                          function(transport, json) {
                          //use and handle foo response data
                         }
                         ,
                         on500:
                          function(transport) {
                          //handle error, inform user
                          },
                         onComplete: parseSendMessage

               });

      }

the problem is in action side server.
there is this PHP / ZEND FRAMEWORK code:



      $request          = urldecode($this-getRequest()-
getRawBody());

      $requestObject = $zendJson-decode($request,
Zend_Json::TYPE_OBJECT);



Json 

[Proto-Scripty] Re: ajax request no works on Chrome - decoding fails

2010-11-08 Thread T.J. Crowder
Hi,

I don't know that it's the problem because I'm not a PHP person, but
you're using the `escape` function to encode your parameters, and then
decoding them with a PHP function called `urldecode`. JavaScript's
`escape` function does _not_ URL-encode things, it does something
similar but different and is almost certainly not what you want. I'm
surprised it's working with other browsers, frankly, but perhaps
that's my lack of PHP knowledge.

The most reliable way to send parameters that I know is to send them
URL-encoded, and to decode them as URL-encoded data. In Prototype, the
easiest way to do that is to supply a plain object to the Ajax.Request
method (which Prototype will correctly encode for you):

var jsonRequest = ...;
new Ajax.Request( // ...
parameters: {json: jsonRequest}
// ...
});

...and then retrieve the value just as you would any other value:

$request = $_POST[json];
$requestObject = Zend_Json::decode($request); // Or your
$zendJson, whatever that is

But again, I'm not a PHP guy and could easily be missing something
important here.

FWIW,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
wrote:
 Hi,

 this is my ajax request that works perfectly on IE and FIREFOX, but
 not in CHROME!

    function sendMessage(baseUrl, idNickRcv, msg) {

       var requestObject       = new Object();
       requestObject.idNickRcv = idNickRcv;
       requestObject.msg       = msg;

       var jsonRequest         = JSON.stringify(requestObject);

       if ((idNickRcv)  (msg)) {

          new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
             method:     'POST',
             requestHeaders:{ Accept:'application/json' },
             parameters: escape(jsonRequest),

                          onSuccess:
                           function(transport, json) {
                           //use and handle foo response data
                          }
                          ,
                          on500:
                           function(transport) {
                           //handle error, inform user
                           },
                          onComplete: parseSendMessage

                });

       }

 the problem is in action side server.
 there is this PHP / ZEND FRAMEWORK code:

 

       $request          = urldecode($this-getRequest()-getRawBody());

       $requestObject = $zendJson-decode($request,
 Zend_Json::TYPE_OBJECT);

 

 Json decoding fails with Syntax Error, for this reason Ajax request no
 works and is interrupted.
 Chrome send a bad json string!

 Any suggests?

-- 
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 no works on Chrome - decoding fails

2010-11-08 Thread Walter Lee Davis
Right. The best low-level way to translate JS to PHP and back again is  
using encodeURI or uncodeURIComponent on your JS side, and  
rawurldecode() or rawurlencode() on the PHP side. They are  
functionally identical, as long as you have set your PHP side to use  
UTF-8 as its default charset.


Walter

On Nov 8, 2010, at 4:42 PM, T.J. Crowder wrote:


Hi,

I don't know that it's the problem because I'm not a PHP person, but
you're using the `escape` function to encode your parameters, and then
decoding them with a PHP function called `urldecode`. JavaScript's
`escape` function does _not_ URL-encode things, it does something
similar but different and is almost certainly not what you want. I'm
surprised it's working with other browsers, frankly, but perhaps
that's my lack of PHP knowledge.

The most reliable way to send parameters that I know is to send them
URL-encoded, and to decode them as URL-encoded data. In Prototype, the
easiest way to do that is to supply a plain object to the Ajax.Request
method (which Prototype will correctly encode for you):

   var jsonRequest = ...;
   new Ajax.Request( // ...
   parameters: {json: jsonRequest}
   // ...
   });

...and then retrieve the value just as you would any other value:

   $request = $_POST[json];
   $requestObject = Zend_Json::decode($request); // Or your
$zendJson, whatever that is

But again, I'm not a PHP guy and could easily be missing something
important here.

FWIW,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Nov 8, 5:47 pm, fashionpeople fashionpeople.busin...@gmail.com
wrote:

Hi,

this is my ajax request that works perfectly on IE and FIREFOX, but
not in CHROME!

   function sendMessage(baseUrl, idNickRcv, msg) {

  var requestObject   = new Object();
  requestObject.idNickRcv = idNickRcv;
  requestObject.msg   = msg;

  var jsonRequest = JSON.stringify(requestObject);

  if ((idNickRcv)  (msg)) {

 new Ajax.Request(baseUrl + '/usermsg/index/sendmessage', {
method: 'POST',
requestHeaders:{ Accept:'application/json' },
parameters: escape(jsonRequest),

 onSuccess:
  function(transport, json) {
  //use and handle foo response data
 }
 ,
 on500:
  function(transport) {
  //handle error, inform user
  },
 onComplete: parseSendMessage

   });

  }

the problem is in action side server.
there is this PHP / ZEND FRAMEWORK code:



  $request  = urldecode($this-getRequest()- 
getRawBody());


  $requestObject = $zendJson-decode($request,
Zend_Json::TYPE_OBJECT);



Json decoding fails with Syntax Error, for this reason Ajax request  
no

works and is interrupted.
Chrome send a bad json string!

Any suggests?


--
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-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 on anchor onclick is buggy in Safari

2010-08-12 Thread Eric
T.J., I was surprised too that the DB would have time to get an update
before the page is unloaded, but I had a closer look at the
example :o)
If the links urls are downloadable file types like the .exe of the
example, the browser will not unload the current page, and the Ajax
request will complete.

Perhaps Safari does unload the page. You may try to specify a target
to the link to force safari to not replace the current page.

Also, I thought that the onclick handler should return a true value
for the link being followed...
Shouldn't you write something like  onclick = return
logClick()... and add a return true at the end of your function?
[1]

The unintrusive approach of Fabien is probably the best here too
(well, not as good as the server side one but if you don't control the
server side...).
However, instead of creating an event for each link, you may observe
the document and use the event bubbling.
It would look like this (untested):
document.observe(click, function(event){
  var link = event.findElement(a.log);
  if(link)
  {
new Ajax.Request('/logger.php?action=1');
  }
});

you may use the link variable to get the href value of the link and
send it to your ajax script.

Advantages are:
- Only one event listener (may cause a difference on IE's memory
leaks)
- It will work with dynamically added links

I removed Fabien's trick to wait the Ajax's return before changing the
location because I think the target attribute will fix the issue[2],
but feel free to use it if there is no other choice (safari users will
have a crappy experience, but it will work...).

Once again, try first to have a server side solution. It will work
better.

Eric

[1] Well, what you really should do is using observe :o)
[2] and like T.J. said, it will reduce user experience.

On Aug 11, 3:02 am, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

 By default, Ajax.Request is *asynchronous*. I'm surprised, frankly,
 that you're seeing many database updates at all, regardless of the
 browser, since a request may not have been transmitted before the page
 gets torn down to make way for the new one. I wouldn't expect it to be
 reliable.

 If you made the requests synchronous, it would likely be fairly
 reliable, but the user experience would be seriously degraded -- the
 entire browser (in most cases) would appear to lock up for a second or
 two before the link was followed. And of course, if the user has
 JavaScript disabled, it's game over.

 As Fabien mentioned, the reliable way to do this is server-side with a
 redirect. His second suggestion (handling the click event, cancelling
 it, sending off an Ajax request, and then triggering the location when
 the request completes) will again result in a degraded user experience
 on multiple levels -- delays (though at least the browser wouldn't
 lock up), shift- and ctrl- click not handled correctly, etc.

 HTH,
 --
 T.J. Crowder
 Independent Software Consultant
 tj / crowder software / comwww.crowdersoftware.com

 On Aug 10, 11:34 pm, JoJo tokyot...@gmail.com wrote:

  I'm collecting stats on user clicking behavior. In this example, I
  write an entry into the database whenever someone clicks a link that
  starts a download:

  a href=program.exe onclick=logClick()download program/a

  function logClick() {
     new Ajax.Request(
        '/logger.php?action=1'
     );

  }

  This works great in Internet Explorer and Firefox. In Firefox, my
  Firebug highlights the request in red as if it's an error. Anyway, I
  see my database being updated, so I'm not too worried. What I'm
  worried about is this fails to work in Safari 4. The only way I can
  get it to work is:

  function logClick() {
     new Ajax.Request(
        '/logger.php?action=1', {
           onSuccess: function(transport) {
              alert(transport.responseText);
           }
        }
     );

  }

  For some reason, this causes the database to be written to.
  Transport.responseText is blank for unknown reasons. How do I get this
  to work without the alert? The alert degrades the user experience.



-- 
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 on anchor onclick is buggy in Safari

2010-08-10 Thread Fabien Ménager
Your method seems really random. You should proceed differently.
Imagine the user has JS disabled, it's click won't be logged, you
should use a server side script that will log the click and redirect
the user to the desired file : href=dispatcher.php?file=program.exe
If you don't have access to the server of can't modify the links, so
you should do like this, but keep in mind that's not the best way to
do this:

add a className to the link you want to log, say log and then make a
little DOM processing to change the link's behavior to log the click,
wait for the log action and then follow the link:

a class=log href=program.exedownload/a
 script type=text/javascript
document.observe(dom:loaded, function(){
  $$(a.log).each(function(e){
e.observe(click, function(event){
new Ajax.Request('/logger.php?action=1', {
   onSuccess: function(transport) {
  location.href=e.href;
   }
};
Event.stop(event);
  );
});
  });
});
/script
On 11 août, 00:34, JoJo tokyot...@gmail.com wrote:
 I'm collecting stats on user clicking behavior. In this example, I
 write an entry into the database whenever someone clicks a link that
 starts a download:

 a href=program.exe onclick=logClick()download program/a

 function logClick() {
    new Ajax.Request(
       '/logger.php?action=1'
    );

 }

 This works great in Internet Explorer and Firefox. In Firefox, my
 Firebug highlights the request in red as if it's an error. Anyway, I
 see my database being updated, so I'm not too worried. What I'm
 worried about is this fails to work in Safari 4. The only way I can
 get it to work is:

 function logClick() {
    new Ajax.Request(
       '/logger.php?action=1', {
          onSuccess: function(transport) {
             alert(transport.responseText);
          }
       }
    );

 }

 For some reason, this causes the database to be written to.
 Transport.responseText is blank for unknown reasons. How do I get this
 to work without the alert? The alert degrades the user experience.

-- 
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 on anchor onclick is buggy in Safari

2010-08-10 Thread T.J. Crowder
Hi,

By default, Ajax.Request is *asynchronous*. I'm surprised, frankly,
that you're seeing many database updates at all, regardless of the
browser, since a request may not have been transmitted before the page
gets torn down to make way for the new one. I wouldn't expect it to be
reliable.

If you made the requests synchronous, it would likely be fairly
reliable, but the user experience would be seriously degraded -- the
entire browser (in most cases) would appear to lock up for a second or
two before the link was followed. And of course, if the user has
JavaScript disabled, it's game over.

As Fabien mentioned, the reliable way to do this is server-side with a
redirect. His second suggestion (handling the click event, cancelling
it, sending off an Ajax request, and then triggering the location when
the request completes) will again result in a degraded user experience
on multiple levels -- delays (though at least the browser wouldn't
lock up), shift- and ctrl- click not handled correctly, etc.

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Aug 10, 11:34 pm, JoJo tokyot...@gmail.com wrote:
 I'm collecting stats on user clicking behavior. In this example, I
 write an entry into the database whenever someone clicks a link that
 starts a download:

 a href=program.exe onclick=logClick()download program/a

 function logClick() {
    new Ajax.Request(
       '/logger.php?action=1'
    );

 }

 This works great in Internet Explorer and Firefox. In Firefox, my
 Firebug highlights the request in red as if it's an error. Anyway, I
 see my database being updated, so I'm not too worried. What I'm
 worried about is this fails to work in Safari 4. The only way I can
 get it to work is:

 function logClick() {
    new Ajax.Request(
       '/logger.php?action=1', {
          onSuccess: function(transport) {
             alert(transport.responseText);
          }
       }
    );

 }

 For some reason, this causes the database to be written to.
 Transport.responseText is blank for unknown reasons. How do I get this
 to work without the alert? The alert degrades the user experience.

-- 
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 PDF to IFRAME

2010-02-11 Thread kstubs
Well thanks for the help on posting a request to the iframe to handle
the PDF. Here is my bigger problem and the reason for my original
thought: how do you trigger code on completion of the PDF load in the
iframe? Of course the original thought was to make an ajax request and
and write the results to the iframe. You then know when therequest is
complete and I'm sure writing to the iframe is fast enough. Is this
possible? Can I get back a binary result from an Ajax request and can
I binary write to the iframe?
Thanks
 Karl..

On Feb 9, 8:06 am, T.J. Crowder t...@crowdersoftware.com wrote:
 Blast (I *hate* double posting), forgot to say: By theIFrameName in
 that code I mean literally the value of a `name` attribute on the
 `iframe` tag (*name*, not *id*).

 -- T.J. :-)

 On Feb 9, 3:05 pm, T.J. Crowder t...@crowdersoftware.com wrote:



  Hi,

   It must be a post to the server, not a get.

  Okay, that's a *few* more lines of code:

      var markup, form;

      markup =
          form id='___unique_form_id___'  +
              method='POST'  +
              action='yoururl'  +
              target='theIFrameName'  +
              style='display: none' +
          input type='hidden' name='param1' value='value1' +
          input type='hidden' name='param2' value='value2' +
          /form;
      $(document.body).insert({bottom: markup});
      form = $('___unique_form_id___');
      form.submit();
      form.remove();

  Quick test on IE7, FF3.6, and Chrome4 all seemed happy. (I wondered if
  I might need a defer in there, but apparently not.)

  HTH,
  --
  T.J. Crowder
  Independent Software Consultant
  tj / crowder software / comwww.crowdersoftware.com

  On Feb 9, 12:03 am, kstubs kst...@gmail.com wrote:

   It must be a post to the server, not a get.

   On Feb 8, 4:22 pm, T.J. Crowder t...@crowdersoftware.com wrote:

Hi,

 Is this possible?

Possible? It's downright easy:

    $('idOfIFrame').src = pathToYourServerScript.xyz;

Very important that your server script set the correct content type,
of course.

I use something similar with a frame (not an iframe), but the concept
should be transferrable.

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / comwww.crowdersoftware.com

On Feb 8, 10:34 pm, kstubs kst...@gmail.com wrote:

 I'm fetching (with Ajax call) a dynamic PDF from the server and would
 like the results to load  into an Iframe (or other html embeded/
 object).

 Is this possible?

 Karl..

-- 
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 PDF to IFRAME

2010-02-09 Thread Peter De Berdt
Generate a form with the necessary values in the iFrame and submit the  
form. That's all I can think off right now.


On 09 Feb 2010, at 01:03, kstubs wrote:


It must be a post to the server, not a get.

On Feb 8, 4:22 pm, T.J. Crowder t...@crowdersoftware.com wrote:

Hi,


Is this possible?


Possible? It's downright easy:

$('idOfIFrame').src = pathToYourServerScript.xyz;

Very important that your server script set the correct content type,
of course.

I use something similar with a frame (not an iframe), but the concept
should be transferrable.




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 PDF to IFRAME

2010-02-09 Thread T.J. Crowder
Hi,

 It must be a post to the server, not a get.

Okay, that's a *few* more lines of code:

var markup, form;

markup =
form id='___unique_form_id___'  +
method='POST'  +
action='yoururl'  +
target='theIFrameName'  +
style='display: none' +
input type='hidden' name='param1' value='value1' +
input type='hidden' name='param2' value='value2' +
/form;
$(document.body).insert({bottom: markup});
form = $('___unique_form_id___');
form.submit();
form.remove();

Quick test on IE7, FF3.6, and Chrome4 all seemed happy. (I wondered if
I might need a defer in there, but apparently not.)

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Feb 9, 12:03 am, kstubs kst...@gmail.com wrote:
 It must be a post to the server, not a get.

 On Feb 8, 4:22 pm, T.J. Crowder t...@crowdersoftware.com wrote:



  Hi,

   Is this possible?

  Possible? It's downright easy:

      $('idOfIFrame').src = pathToYourServerScript.xyz;

  Very important that your server script set the correct content type,
  of course.

  I use something similar with a frame (not an iframe), but the concept
  should be transferrable.

  HTH,
  --
  T.J. Crowder
  Independent Software Consultant
  tj / crowder software / comwww.crowdersoftware.com

  On Feb 8, 10:34 pm, kstubs kst...@gmail.com wrote:

   I'm fetching (with Ajax call) a dynamic PDF from the server and would
   like the results to load  into an Iframe (or other html embeded/
   object).

   Is this possible?

   Karl..

-- 
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 PDF to IFRAME

2010-02-09 Thread T.J. Crowder
Blast (I *hate* double posting), forgot to say: By theIFrameName in
that code I mean literally the value of a `name` attribute on the
`iframe` tag (*name*, not *id*).

-- T.J. :-)

On Feb 9, 3:05 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

  It must be a post to the server, not a get.

 Okay, that's a *few* more lines of code:

     var markup, form;

     markup =
         form id='___unique_form_id___'  +
             method='POST'  +
             action='yoururl'  +
             target='theIFrameName'  +
             style='display: none' +
         input type='hidden' name='param1' value='value1' +
         input type='hidden' name='param2' value='value2' +
         /form;
     $(document.body).insert({bottom: markup});
     form = $('___unique_form_id___');
     form.submit();
     form.remove();

 Quick test on IE7, FF3.6, and Chrome4 all seemed happy. (I wondered if
 I might need a defer in there, but apparently not.)

 HTH,
 --
 T.J. Crowder
 Independent Software Consultant
 tj / crowder software / comwww.crowdersoftware.com

 On Feb 9, 12:03 am, kstubs kst...@gmail.com wrote:



  It must be a post to the server, not a get.

  On Feb 8, 4:22 pm, T.J. Crowder t...@crowdersoftware.com wrote:

   Hi,

Is this possible?

   Possible? It's downright easy:

       $('idOfIFrame').src = pathToYourServerScript.xyz;

   Very important that your server script set the correct content type,
   of course.

   I use something similar with a frame (not an iframe), but the concept
   should be transferrable.

   HTH,
   --
   T.J. Crowder
   Independent Software Consultant
   tj / crowder software / comwww.crowdersoftware.com

   On Feb 8, 10:34 pm, kstubs kst...@gmail.com wrote:

I'm fetching (with Ajax call) a dynamic PDF from the server and would
like the results to load  into an Iframe (or other html embeded/
object).

Is this possible?

Karl..

-- 
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 PDF to IFRAME

2010-02-08 Thread T.J. Crowder
Hi,

 Is this possible?

Possible? It's downright easy:

$('idOfIFrame').src = pathToYourServerScript.xyz;

Very important that your server script set the correct content type,
of course.

I use something similar with a frame (not an iframe), but the concept
should be transferrable.

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Feb 8, 10:34 pm, kstubs kst...@gmail.com wrote:
 I'm fetching (with Ajax call) a dynamic PDF from the server and would
 like the results to load  into an Iframe (or other html embeded/
 object).

 Is this possible?

 Karl..

-- 
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 PDF to IFRAME

2010-02-08 Thread kstubs
It must be a post to the server, not a get.

On Feb 8, 4:22 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

  Is this possible?

 Possible? It's downright easy:

     $('idOfIFrame').src = pathToYourServerScript.xyz;

 Very important that your server script set the correct content type,
 of course.

 I use something similar with a frame (not an iframe), but the concept
 should be transferrable.

 HTH,
 --
 T.J. Crowder
 Independent Software Consultant
 tj / crowder software / comwww.crowdersoftware.com

 On Feb 8, 10:34 pm, kstubs kst...@gmail.com wrote:



  I'm fetching (with Ajax call) a dynamic PDF from the server and would
  like the results to load  into an Iframe (or other html embeded/
  object).

  Is this possible?

  Karl..

-- 
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

2009-11-10 Thread Alex McAuley

Could be the web server ...

Alot of web servers have a max number of paralell  requests per user


Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: ziva znibers...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Tuesday, November 10, 2009 4:05 AM
Subject: [Proto-Scripty] ajax request



 hi everybody
 i have an issue with ajax requests, when i send two requests one after
 the other the second one waits for the first one to finish , and of
 course i specify that they are asynchronous.
 anybody has an explanation for 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-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

2009-11-10 Thread T.J. Crowder

Hi,

Nearly identical questions at almost the same time. :-)

Here's the other one, where I've posted an answer:
http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/6af62cd45d76f06e

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

On Nov 10, 4:05 am, ziva znibers...@gmail.com wrote:
 hi everybody
 i have an issue with ajax requests, when i send two requests one after
 the other the second one waits for the first one to finish , and of
 course i specify that they are asynchronous.
 anybody has an explanation for 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-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

2009-11-10 Thread Alex McAuley

And identical (almost) answers !! - how bizarre!!!
Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: T.J. Crowder t...@crowdersoftware.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Tuesday, November 10, 2009 11:51 AM
Subject: [Proto-Scripty] Re: ajax request



Hi,

Nearly identical questions at almost the same time. :-)

Here's the other one, where I've posted an answer:
http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/6af62cd45d76f06e

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

On Nov 10, 4:05 am, ziva znibers...@gmail.com wrote:
 hi everybody
 i have an issue with ajax requests, when i send two requests one after
 the other the second one waits for the first one to finish , and of
 course i specify that they are asynchronous.
 anybody has an explanation for 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-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 Timeout

2009-07-15 Thread Rick

@Matt Foster: your patch didn't work for me ??

in ff i didn't get the onTimeout event  or if you get then it
happend when the server is back online
an the as often as it should happend while the offline time.

i don't know why?

i use an PeriodicalExecuter for my ajax request ...

that's how i do it without timeout:
--my apps
code---
new PeriodicalExecuter(
function (pe) {

var successListener = function(transport, json){
appendPost('posts', 
transport.responseJSON);
scrollToEnd();

//FireBUG###
console.log(Event : ,AJAX : Request 
successed);
//FireBUG###
};

var failureListener = function(transport, json){
show_alert('Fehler beim Aufbau der 
Verbindung zum Server.');

//FireBUG###
console.log(Event : ,AJAX : Request 
failed);
//FireBUG###
};

var exceptionListener = function(transport, 
json){
show_alert('Es liegt eine unbekannter 
Fehler vor.');

//FireBUG###
console.error(Event : ,AJAX : 
Request exception happend);
//FireBUG###
};

new Ajax.Request('app.php', {
method:'post',
parameters: { controller: 'check' },
onSuccess: successListener,
onException: exceptionListener,
onFailure: failureListener
});

}, 4);
---

i've used your patch an added an onTimeout event an the other stuff,
but under Firefox this event just happend when the server is back
online
under InternetExplorer it worked fine???!
--~--~-~--~~~---~--~~
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 Timeout

2009-07-14 Thread Rick

hi

 But leaving aside status 0, just a logical point.  The third condition
 in your updated code:

      return (status = 200  status  300  status != 0); 

 ...is irrelevant and will never be evaluated.  If 200 = x  300, x
 cannot be zero.

i can't believe what piece rubbish of code i have written, my brain
must have bin offline :'(


i think the zero comes from that part:
--- line: 1499--
  getStatus: function() {
try {
  return this.transport.status || 0;
} catch (e) { return 0 }
  }
---

so Firefox must leave the status undefined.


@ Matt Foster : i tried your patch but it didn't work for me,
but maybe its my fault ... maybe it was a bad day of coding for me :)

i will try it again  yes the Ajax part off prototype is a bit
uncomfortable


by the way sorry I am not a native English speaker, so don't be
mad with 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 Timeout

2009-07-14 Thread Matt Foster

Hey Rick,

  My proposed idea in that article requires you to actually
redefine the Ajax.Request.  If we can solidify the idea we could
submit the code as a patch to core but as of now you've gotta either
replace it in the source library itself or just redefine it after the
library but before any implementation.

Review that demo page to see how I had done it and you could probably
get it working.



On Jul 14, 1:57 pm, Rick dun...@googlemail.com wrote:
 hi

  But leaving aside status 0, just a logical point.  The third condition
  in your updated code:

       return (status = 200  status  300  status != 0); 

  ...is irrelevant and will never be evaluated.  If 200 = x  300, x
  cannot be zero.

 i can't believe what piece rubbish of code i have written, my brain
 must have bin offline :'(

 i think the zero comes from that part:
 --- line: 1499--
   getStatus: function() {
     try {
       return this.transport.status || 0;
     } catch (e) { return 0 }
   }
 ---

 so Firefox must leave the status undefined.

 @ Matt Foster : i tried your patch but it didn't work for me,
 but maybe its my fault ... maybe it was a bad day of coding for me :)

 i will try it again  yes the Ajax part off prototype is a bit
 uncomfortable

 by the way sorry I am not a native English speaker, so don't be
 mad with 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 Timeout

2009-07-14 Thread Matt Foster

Yeah I discuss the idea of having its own event for timing out in my
article.  The argument is a timeout is a failure, its failed to
retrieve a response in the given time.  So a timeout is basically like
an inherited event from onFailure.  Question remains do you seperate
the event or just add a flag to the XHR to indicate the reason for
failure is its timed out.  Obviously you side with the latter as did
Tobie so perhaps it would be best to dispatch both events for ease of
implementation.

Also that success method looks exactly like what TJ suggested and I
posted, so good going on that.



On Jul 14, 3:56 pm, Rick dun...@googlemail.com wrote:
 currently i just fixed the success function

 success: function() {
     var status = this.getStatus();
     return (status = 200  status  300);
   },

 and just watch the onFailure and onException event.

 But i would like to have an onTimeout event, so if we get an solution
 for a crossbrowser working onTimeout event, we can submit it.
 I have read about an solution but this one was rejected because it
 didn't worked in safari, etc.
--~--~-~--~~~---~--~~
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 - select element

2009-06-16 Thread fufolewe

Hi,

thx a lot for your help.

@Colin

doesn't work means it returns NULL ;)
But of course, you are right.

I already feared that the A string is not a document/DOM is the main
problem.

@T.J. Crowder

thx! I'll try this soon, it looks promising :)

I already created a regEx solution but it's too unflexible for my
needs (handle div,li',span,...alt...title tags..maybe additional
style info and so on makes the regEx quite hard ..)






On 15 Jun., 13:41, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

 As Colin points out, you're trying to treat a String object like a
 Document (by calling getElementById), which isn't going to work.

 You have a couple of options.

 1. Use string parsing to isolate the markup in that string for the
 element you want.  Once you have just that markup, you can use that
 with the #update call.  This could be fairly challenging to do in the
 general case (or maybe you have massive Regex fu), but perhaps in your
 specific case it might be simpler.

 2. Alternately, use a document fragment[1][2].  This is to a large
 extent what document fragments are for -- holding copies of things and
 mucking about with them off-to-the-side.  I was surprised not to have
 an example lying around and wanted to refresh my memory, so here's a
 small example:

 http://pastie.org/512428

 (Supply your own 'fragment2.html'; it can be any valid HTML doc, make
 sure it has an element with the ID 'two' in it -- or change the ID
 used in the example.)

 Basically, I request the page via Ajax.Request, then create a fragment
 to hold the result and (because I'm lazy) a div inside that fragment
 so that I can use Prototype's Element#update function.  I put the
 retrieved document inside the div (almost certainly creating a
 completely invalid document temporarily!), then go find the element
 inside that with the ID I want, and update a target div with that
 element.

 Note this line:

     elm = findElementByID(div, 'two');

 I coded up a quick recursive-descent lookup function for finding the
 element by ID because you can't use document.getElementById (or
 Prototype's $) to find it in the fragment -- the fragment isn't in the
 document (which is probably a good thing, otherwise you'd be massively
 worried about ID conflicts loading up an entire page like this).
 Interestingly, if you're using Prototype 1.6.1 RC2, you could (as of
 the time of this writing) use:

     elm = div.select('#two');

 ...instead, because apparently Prototype's new Sizzle-based selector
 engine finds the element correctly, wheras in 1.6.0.3 the old selector
 engine doesn't.  But I wouldn't.  Firstly, the simple recursive-
 descent function is small and doesn't take long; secondly, I wouldn't
 bet on future changes not causing Element#select to stop working in
 this context -- barring finding documentation saying that it will, of
 course.  I don't know Sizzle well enough to know if it intentionally
 handles this situation.

 [1]https://developer.mozilla.org/en/dom/documentfragment
 [2]http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-B63ED1A3

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Jun 13, 10:04 pm, fufolewe rentsch.dan...@gmail.com wrote:

  Hi,

  I have a simple problem which is driving me nuts:

  I would like to make an AJAX req which returns the whole page - select
  an element by its ID from the response text and update targetDiv
  with this element (myDivID).

  But it doenst work :/

  function loadContent(url) {

          new Ajax.Request(url, {
                          method: 'get',
                          onSuccess: function(transport) {

                          var response = transport.responseText;

                          var element = response.getElementById( 'myDivID');

                          $('targetDiv').update(element);

                          }
          });

  }

  Some ideas?

  thx
--~--~-~--~~~---~--~~
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 - select element

2009-06-16 Thread Alex McAuley

You could always update the response into a hidden iframe and search that - 
i am pretty sure this works



- Original Message - 
From: fufolewe rentsch.dan...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Tuesday, June 16, 2009 10:49 AM
Subject: [Proto-Scripty] Re: AJAX request - select element



Hi,

thx a lot for your help.

@Colin

doesn't work means it returns NULL ;)
But of course, you are right.

I already feared that the A string is not a document/DOM is the main
problem.

@T.J. Crowder

thx! I'll try this soon, it looks promising :)

I already created a regEx solution but it's too unflexible for my
needs (handle div,li',span,...alt...title tags..maybe additional
style info and so on makes the regEx quite hard ..)






On 15 Jun., 13:41, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

 As Colin points out, you're trying to treat a String object like a
 Document (by calling getElementById), which isn't going to work.

 You have a couple of options.

 1. Use string parsing to isolate the markup in that string for the
 element you want. Once you have just that markup, you can use that
 with the #update call. This could be fairly challenging to do in the
 general case (or maybe you have massive Regex fu), but perhaps in your
 specific case it might be simpler.

 2. Alternately, use a document fragment[1][2]. This is to a large
 extent what document fragments are for -- holding copies of things and
 mucking about with them off-to-the-side. I was surprised not to have
 an example lying around and wanted to refresh my memory, so here's a
 small example:

 http://pastie.org/512428

 (Supply your own 'fragment2.html'; it can be any valid HTML doc, make
 sure it has an element with the ID 'two' in it -- or change the ID
 used in the example.)

 Basically, I request the page via Ajax.Request, then create a fragment
 to hold the result and (because I'm lazy) a div inside that fragment
 so that I can use Prototype's Element#update function. I put the
 retrieved document inside the div (almost certainly creating a
 completely invalid document temporarily!), then go find the element
 inside that with the ID I want, and update a target div with that
 element.

 Note this line:

 elm = findElementByID(div, 'two');

 I coded up a quick recursive-descent lookup function for finding the
 element by ID because you can't use document.getElementById (or
 Prototype's $) to find it in the fragment -- the fragment isn't in the
 document (which is probably a good thing, otherwise you'd be massively
 worried about ID conflicts loading up an entire page like this).
 Interestingly, if you're using Prototype 1.6.1 RC2, you could (as of
 the time of this writing) use:

 elm = div.select('#two');

 ...instead, because apparently Prototype's new Sizzle-based selector
 engine finds the element correctly, wheras in 1.6.0.3 the old selector
 engine doesn't. But I wouldn't. Firstly, the simple recursive-
 descent function is small and doesn't take long; secondly, I wouldn't
 bet on future changes not causing Element#select to stop working in
 this context -- barring finding documentation saying that it will, of
 course. I don't know Sizzle well enough to know if it intentionally
 handles this situation.

 [1]https://developer.mozilla.org/en/dom/documentfragment
 [2]http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-B63ED1A3

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Jun 13, 10:04 pm, fufolewe rentsch.dan...@gmail.com wrote:

  Hi,

  I have a simple problem which is driving me nuts:

  I would like to make an AJAX req which returns the whole page - select
  an element by its ID from the response text and update targetDiv
  with this element (myDivID).

  But it doenst work :/

  function loadContent(url) {

  new Ajax.Request(url, {
  method: 'get',
  onSuccess: function(transport) {

  var response = transport.responseText;

  var element = response.getElementById( 'myDivID');

  $('targetDiv').update(element);

  }
  });

  }

  Some ideas?

  thx



--~--~-~--~~~---~--~~
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 - select element

2009-06-16 Thread ColinFine



On Jun 15, 1:41 pm, T.J. Crowder t...@crowdersoftware.com wrote:

 2. Alternately, use a document fragment[1][2].  This is to a large
 extent what document fragments are for -- holding copies of things and
 mucking about with them off-to-the-side.  I was surprised not to have
 an example lying around and wanted to refresh my memory, so here's a
 small example:


Wow!

Thanks, TJ. I'd no idea DocumentFragment existed.


--~--~-~--~~~---~--~~
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 - select element

2009-06-15 Thread T.J. Crowder

Hi,

As Colin points out, you're trying to treat a String object like a
Document (by calling getElementById), which isn't going to work.

You have a couple of options.

1. Use string parsing to isolate the markup in that string for the
element you want.  Once you have just that markup, you can use that
with the #update call.  This could be fairly challenging to do in the
general case (or maybe you have massive Regex fu), but perhaps in your
specific case it might be simpler.

2. Alternately, use a document fragment[1][2].  This is to a large
extent what document fragments are for -- holding copies of things and
mucking about with them off-to-the-side.  I was surprised not to have
an example lying around and wanted to refresh my memory, so here's a
small example:

http://pastie.org/512428

(Supply your own 'fragment2.html'; it can be any valid HTML doc, make
sure it has an element with the ID 'two' in it -- or change the ID
used in the example.)

Basically, I request the page via Ajax.Request, then create a fragment
to hold the result and (because I'm lazy) a div inside that fragment
so that I can use Prototype's Element#update function.  I put the
retrieved document inside the div (almost certainly creating a
completely invalid document temporarily!), then go find the element
inside that with the ID I want, and update a target div with that
element.

Note this line:

elm = findElementByID(div, 'two');

I coded up a quick recursive-descent lookup function for finding the
element by ID because you can't use document.getElementById (or
Prototype's $) to find it in the fragment -- the fragment isn't in the
document (which is probably a good thing, otherwise you'd be massively
worried about ID conflicts loading up an entire page like this).
Interestingly, if you're using Prototype 1.6.1 RC2, you could (as of
the time of this writing) use:

elm = div.select('#two');

...instead, because apparently Prototype's new Sizzle-based selector
engine finds the element correctly, wheras in 1.6.0.3 the old selector
engine doesn't.  But I wouldn't.  Firstly, the simple recursive-
descent function is small and doesn't take long; secondly, I wouldn't
bet on future changes not causing Element#select to stop working in
this context -- barring finding documentation saying that it will, of
course.  I don't know Sizzle well enough to know if it intentionally
handles this situation.

[1] https://developer.mozilla.org/en/dom/documentfragment
[2] http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-B63ED1A3

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Jun 13, 10:04 pm, fufolewe rentsch.dan...@gmail.com wrote:
 Hi,

 I have a simple problem which is driving me nuts:

 I would like to make an AJAX req which returns the whole page - select
 an element by its ID from the response text and update targetDiv
 with this element (myDivID).

 But it doenst work :/

 function loadContent(url) {

         new Ajax.Request(url, {
                         method: 'get',
                         onSuccess: function(transport) {

                         var response = transport.responseText;

                         var element = response.getElementById( 'myDivID');

                         $('targetDiv').update(element);

                         }
         });

 }

 Some ideas?

 thx
--~--~-~--~~~---~--~~
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 to XML-RPC webservice

2009-05-20 Thread T.J. Crowder

Hi,

You're running into something called the Same Origin Policy, details
here.[1]  Basically, you can't use the XmlHttpRequest object to
request resources from a different origin than the page in which the
script is running, and origin includes the port.

[1] http://en.wikipedia.org/wiki/Same_origin_policy

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On May 20, 10:38 am, kfrancoi kfran...@gmail.com wrote:
 Hello everyone,

 This is my first intervention in this mailing list.  I have been
 looking for a few days on how to call an XML-RPC webservice from a
 JavaScript client.

 I found a JS librarie (XOAP_Request :http://dsone.nl/xoap/usage.html)
 that depend on prototype and that build the XML message to be send
 with AJAX.Request().

 My webservice is running on port 8000 on my server. My web page is
 running on port 80 of the same server.

 When I launch the AJAXX request using FireFox, I get the following JS
 warning, and nothing happen next :
 **
 Security Error: Content athttp://XXX.XXX.XXX.XXX/client2.htmlmay not
 load data fromhttp://XXX.XXX.XXX.XXX:8000/.
 **

 When I launch the same request using Safari, the request access the
 server but it generate an error 501 (message Unsupported method
 OPTION).

 Using anything else (PHP, Python, ...)  to call my webservice make it
 work.

 Does someone have a clue of what the problem could be ?

 Thank a lot for any help !!

 Kevin
--~--~-~--~~~---~--~~
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 doesn't work on some computers?

2009-04-07 Thread Walter Lee Davis

Is there a reason why you are using complete URLs in your call?

var categoriesInitUrl = 'http://www.tonerize.com/catalog/picker/categories/' 
;

You might get better mileage by making these relative URLs.

var categoriesInitUrl = '/catalog/picker/categories/';

Walter

On Apr 7, 2009, at 10:52 AM, Yaron wrote:

 Does anyone have any idea why we're having a problem here? It's not
 like the request is sent and nothing is sent back. The request is not
 even made when it doesn't work.


--~--~-~--~~~---~--~~
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 doesn't work on some computers?

2009-04-07 Thread T.J. Crowder

Hi,

 However on some computers the request is never even sent, and we can't
 figure out why.

Have you eliminated things like what brand of browser they're using,
etc.?

Walter's point about the URL well-taken, and I see that you've already
fixed it for the bit he mentioned.  That's a good idea, because if I
go to http://tonerize.com instead of http://www.tonerize.com, then an
Ajax request to http://www.tonerize.com won't work because
tonerize.com and www.tonerize.com are not the same thing.  So if some
of your users were going to http://tonerize.com (I checked and you're
not redirecting them over to the www version), that might explain why
the calls were failing.  (You'd already updated it before I tried, so
I don't know that that's really what was happening.)

You're still using the complete URL in lots of places (various
includes, your call to initAutocompleter, etc.).  If you make
*everything* relative, things should go a bit more smoothly for you...

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Apr 7, 6:27 pm, Walter Lee Davis wa...@wdstudio.com wrote:
 Is there a reason why you are using complete URLs in your call?

 var categoriesInitUrl = 'http://www.tonerize.com/catalog/picker/categories/'
 ;

 You might get better mileage by making these relative URLs.

 var categoriesInitUrl = '/catalog/picker/categories/';

 Walter

 On Apr 7, 2009, at 10:52 AM, Yaron wrote:

  Does anyone have any idea why we're having a problem here? It's not
  like the request is sent and nothing is sent back. The request is not
  even made when it doesn't work.


--~--~-~--~~~---~--~~
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 doesn't work on some computers?

2009-04-07 Thread Yaron

Wow you were right that was exactly the issue. I know you can't use
Ajax cross-domain but I had no idea that putting in the full URL would
cause problems. It was also very strange because it only happened on
certain computers / browsers.

Regardless, thanks so much for your help!

On Apr 7, 1:27 pm, Walter Lee Davis wa...@wdstudio.com wrote:
 Is there a reason why you are using complete URLs in your call?

 var categoriesInitUrl = 'http://www.tonerize.com/catalog/picker/categories/'
 ;

 You might get better mileage by making these relative URLs.

 var categoriesInitUrl = '/catalog/picker/categories/';

 Walter

 On Apr 7, 2009, at 10:52 AM, Yaron wrote:

  Does anyone have any idea why we're having a problem here? It's not
  like the request is sent and nothing is sent back. The request is not
  even made when it doesn't work.


--~--~-~--~~~---~--~~
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 doesn't work on some computers?

2009-04-07 Thread T.J. Crowder

Hi,

Sorry, sent too soon.  When I said aren't the same thing, I mean in
terms of the Same Origin Policy[1].

[1] http://en.wikipedia.org/wiki/Same_origin_policy

HTH,

-- T.J.

On Apr 7, 7:00 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

  However on some computers the request is never even sent, and we can't
  figure out why.

 Have you eliminated things like what brand of browser they're using,
 etc.?

 Walter's point about the URL well-taken, and I see that you've already
 fixed it for the bit he mentioned.  That's a good idea, because if I
 go tohttp://tonerize.cominstead ofhttp://www.tonerize.com, then an
 Ajax request tohttp://www.tonerize.comwon't work because
 tonerize.com andwww.tonerize.comare not the same thing.  So if some
 of your users were going tohttp://tonerize.com(I checked and you're
 not redirecting them over to the www version), that might explain why
 the calls were failing.  (You'd already updated it before I tried, so
 I don't know that that's really what was happening.)

 You're still using the complete URL in lots of places (various
 includes, your call to initAutocompleter, etc.).  If you make
 *everything* relative, things should go a bit more smoothly for you...

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Apr 7, 6:27 pm, Walter Lee Davis wa...@wdstudio.com wrote:

  Is there a reason why you are using complete URLs in your call?

  var categoriesInitUrl = 'http://www.tonerize.com/catalog/picker/categories/'
  ;

  You might get better mileage by making these relative URLs.

  var categoriesInitUrl = '/catalog/picker/categories/';

  Walter

  On Apr 7, 2009, at 10:52 AM, Yaron wrote:

   Does anyone have any idea why we're having a problem here? It's not
   like the request is sent and nothing is sent back. The request is not
   even made when it doesn't work.


--~--~-~--~~~---~--~~
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 doesn't work on some computers?

2009-04-07 Thread Yaron

TJ, thanks for you indepth reply and the link to the Wiki post. Point
well taken from both you and Walter. One thing I will definitely do
before anything else is redirect tonerize.com to www.tonerize.com, so
that I can alleviate any of these issues before I make all of the
calls relative!

Thanks again!

On Apr 7, 2:14 pm, Yaron ylibr...@gmail.com wrote:
 Wow you were right that was exactly the issue. I know you can't use
 Ajax cross-domain but I had no idea that putting in the full URL would
 cause problems. It was also very strange because it only happened on
 certain computers / browsers.

 Regardless, thanks so much for your help!

 On Apr 7, 1:27 pm, Walter Lee Davis wa...@wdstudio.com wrote:

  Is there a reason why you are using complete URLs in your call?

  var categoriesInitUrl = 'http://www.tonerize.com/catalog/picker/categories/'
  ;

  You might get better mileage by making these relative URLs.

  var categoriesInitUrl = '/catalog/picker/categories/';

  Walter

  On Apr 7, 2009, at 10:52 AM, Yaron wrote:

   Does anyone have any idea why we're having a problem here? It's not
   like the request is sent and nothing is sent back. The request is not
   even made when it doesn't work.


--~--~-~--~~~---~--~~
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 Encoding issue iso-8859-1

2008-11-25 Thread Walter Lee Davis

If you read the Prototype documentation, you will see that Prototype  
uses UTF-8 internally, and if you read the W3C recommendations, you  
will see that UTF-8 is the preferred and expected encoding for Web  
sites.

So what is your issue specifically? Are you unable to set your server  
to correspond in UTF-8? It's a fairly trivial exercise in most modern  
frameworks, usually just a single config file edit away.

Walter

On Nov 25, 2008, at 2:32 AM, AS wrote:

  why Ajax request in the following
 manner is not setting up the correct encoding. It looks like prototype
 is using default utf-8 encoding.


--~--~-~--~~~---~--~~
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 encoding

2008-10-22 Thread João Paulo Mafra
Hi Baglan,

I'm already doing that. However, in the server I must convert from one
charset to another programmaticaly.

The problem seems to be the use of encodeURIComponent function by
prototype:

Mozilla Developer Core Javascript
Guidehttp://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponentwrote:

 encodeURIComponent



Encodes a Uniform Resource Identifier (URI) by replacing each instance of
 certain characters by one, two, or three escape sequences representing the
 UTF-8 encoding of the character.


Replacing all occurences of encodeURIComponent function by escape
function solved the problem. The question is whether using escape is worth
for that.

Mozilla Developer Core Javascript
Guidehttps://developer.mozilla.org/En/Core_JavaScript_1.5_Guide:Predefined_Functions:escape_and_unescape_Functionswrote:

 escape and unescape



The escape and unescape functions let you encode and decode strings. The
 escape function returns the hexadecimal encoding of an argument in the ISO
 Latin character set. The unescape function returns the 
 ASCIIhttp://xkr.us/articles/javascript/encode-compare/#ref-ascii

string for the specified hexadecimal encoding value.



The article on http://xkr.us/articles/javascript/encode-compare/#ref-js-nsshows
the differences between some functions to encode strings.

Is there any chance to enhance prototype to use the correct function based
on an encoding parameter?


Thanks a lot. (sorry my bad english) :D


2008/10/22 Baglan [EMAIL PROTECTED]


 Hello!

 The 'encoding' option seems not to be doing much. Request is sent in
 UTF-8 and response encoding is determined by the encoding conveyed in
 the HTTP header of the response.

 In practical terms, you can skip the 'encoding' parameter, expect data
 in UTF-8 on the server and set response content type and charset to:

 text/html; charset=iso-8859-1

 - Baglan
 


--~--~-~--~~~---~--~~
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 encoding

2008-10-22 Thread João Paulo Mafra

(I'm resending my last message in plain text after viewing it on
google groups, which is in html and with formatting errors)

Hi Baglan,

I'm already doing that. However, in the server I must convert from one
charset to another programmaticaly.

The problem seems to be the use of encodeURIComponent function by prototype:

Mozilla Developer Core Javascript Guide
(http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent):
encodeURIComponent
Encodes a Uniform Resource Identifier (URI) by replacing each instance
of certain characters by one, two, or three escape sequences
representing the UTF-8 encoding of the character.

Replacing all occurences of encodeURIComponent function by escape
function solved the problem. The question is whether using escape is
worth for that.

Mozilla Developer Core Javascript Guide
(http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Predefined_Functions:escape_and_unescape_Functions):
escape and unescape
The escape and unescape functions let you encode and decode strings.
The escape function returns the hexadecimal encoding of an argument in
the ISO Latin character set. The unescape function returns the ASCII
string for the specified hexadecimal encoding value.

The article on http://xkr.us/articles/javascript/encode-compare/#ref-js-ns
shows the differences between some functions to encode strings.

Is there any chance to enhance prototype to use the correct function
based on an encoding parameter?


Thanks a lot. (sorry my bad english) :D

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---