AJAX callback:value: via POST message

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

AJAX callback:value: via POST message

Esteban A. Maringolo
Hi,

I'm currently doing a an AJAX call with #callback:value: where the value
is a stringified JSON I built at client side and which on completion
returns a script file. But the value payload is passed encoded in the
URI, and this has a size limit.

Is there a way to do a callback:value: using POST instead of GET?

The call is something like this:

( html jQuery id: self tableId )
  on: 'paste'
  selector: nil
  data: ( ( html jQuery ajax )
    callback: [ :json | self pasteMatrix: ( WAJsonParser parse: json ) ]
      value: ( JSStream on: 'JSON.stringify(arguments[0])' );
    onComplete: ( html jQuery ajax
      script: [ :s | self scriptValidatedReloadOn: s ] ) ) asFunction.
  call: (JSStream on: 'pasteHandler' )


And I'd like to have a POST based function that sends the JSON string in
it's `data` payload instead.

Regards,


Appendix A:

`pasteHandler` is a custom function that detects if the contents being
pasted into a text input are not a single value but instead are values
copied from an Excel file, in tab separated format, and if so overrides
the event propagation, creates a matrix (array of arrays), and calls the
function passed to the `data:` parameter in the event handler.

Because the inputs are presented as separate <input> tags within a
table, that's the only way I found to preserve the convenience of having
separate inputs, but with the behavior of a single "grid" for pasting
(and copying) data.


function pasteHandler(event){
  var clipboardData, pastedData;
  var e = event.originalEvent;
  var matrix;

  clipboardData = e.clipboardData || window.clipboardData;
  if (!clipboardData) return false;

  pastedData = clipboardData.getData("Text");
  matrix = tabMatrix(pastedData);
  if (isMatrix(matrix)) {
    // Stop data actually being pasted
    var point = pastePoint(e.target);
    var matrixHandler = event.data;
    if (matrixHandler) {
      e.stopPropagation();
      e.preventDefault();
      matrixHandler({"matrix": matrix, "point": point});
    }
  }
}


--
Esteban A. Maringolo
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: AJAX callback:value: via POST message

Gabriel Cotelli
You can do

ajax type: 'POST'

and it will use POST insted of GET.

On Thu, Jun 21, 2018 at 10:07 AM, Esteban A. Maringolo <[hidden email]> wrote:
Hi,

I'm currently doing a an AJAX call with #callback:value: where the value
is a stringified JSON I built at client side and which on completion
returns a script file. But the value payload is passed encoded in the
URI, and this has a size limit.

Is there a way to do a callback:value: using POST instead of GET?

The call is something like this:

( html jQuery id: self tableId )
  on: 'paste'
  selector: nil
  data: ( ( html jQuery ajax )
    callback: [ :json | self pasteMatrix: ( WAJsonParser parse: json ) ]
      value: ( JSStream on: 'JSON.stringify(arguments[0])' );
    onComplete: ( html jQuery ajax
      script: [ :s | self scriptValidatedReloadOn: s ] ) ) asFunction.
  call: (JSStream on: 'pasteHandler' )


And I'd like to have a POST based function that sends the JSON string in
it's `data` payload instead.

Regards,


Appendix A:

`pasteHandler` is a custom function that detects if the contents being
pasted into a text input are not a single value but instead are values
copied from an Excel file, in tab separated format, and if so overrides
the event propagation, creates a matrix (array of arrays), and calls the
function passed to the `data:` parameter in the event handler.

Because the inputs are presented as separate <input> tags within a
table, that's the only way I found to preserve the convenience of having
separate inputs, but with the behavior of a single "grid" for pasting
(and copying) data.


function pasteHandler(event){
  var clipboardData, pastedData;
  var e = event.originalEvent;
  var matrix;

  clipboardData = e.clipboardData || window.clipboardData;
  if (!clipboardData) return false;

  pastedData = clipboardData.getData("Text");
  matrix = tabMatrix(pastedData);
  if (isMatrix(matrix)) {
    // Stop data actually being pasted
    var point = pastePoint(e.target);
    var matrixHandler = event.data;
    if (matrixHandler) {
      e.stopPropagation();
      e.preventDefault();
      matrixHandler({"matrix": matrix, "point": point});
    }
  }
}


--
Esteban A. Maringolo
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--


Gabriel O. Cotelli
Desarrollo y Tecnología
Mercap
Tel: +54 (011) 5352.2372 al 74
http://www.mercapsoftware.com
This message is confidential. It may also contain information that is privileged or otherwise legally exempt from disclosure. If you have received it by mistake please let us know by e-mail immediately and delete it from your system; also you shouldn't copy the message nor disclose its contents to anyone. Thanks.


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: AJAX callback:value: via POST message

Esteban A. Maringolo
I've tried several, way elaborated ways but didn't try the most
elemental. :)

Thanks, it works as expected.


On 21/06/2018 12:59, Gabriel Cotelli wrote:

> You can do
>
> ajax type: 'POST'
>
> and it will use POST insted of GET.
>
> On Thu, Jun 21, 2018 at 10:07 AM, Esteban A. Maringolo
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi,
>
>     I'm currently doing a an AJAX call with #callback:value: where the value
>     is a stringified JSON I built at client side and which on completion
>     returns a script file. But the value payload is passed encoded in the
>     URI, and this has a size limit.
>
>     Is there a way to do a callback:value: using POST instead of GET?
>
>     The call is something like this:
>
>     ( html jQuery id: self tableId )
>       on: 'paste'
>       selector: nil
>       data: ( ( html jQuery ajax )
>         callback: [ :json | self pasteMatrix: ( WAJsonParser parse: json ) ]
>           value: ( JSStream on: 'JSON.stringify(arguments[0])' );
>         onComplete: ( html jQuery ajax
>           script: [ :s | self scriptValidatedReloadOn: s ] ) ) asFunction.
>       call: (JSStream on: 'pasteHandler' )
>
>
>     And I'd like to have a POST based function that sends the JSON string in
>     it's `data` payload instead.
>
>     Regards,
>
>
>     Appendix A:
>
>     `pasteHandler` is a custom function that detects if the contents being
>     pasted into a text input are not a single value but instead are values
>     copied from an Excel file, in tab separated format, and if so overrides
>     the event propagation, creates a matrix (array of arrays), and calls the
>     function passed to the `data:` parameter in the event handler.
>
>     Because the inputs are presented as separate <input> tags within a
>     table, that's the only way I found to preserve the convenience of having
>     separate inputs, but with the behavior of a single "grid" for pasting
>     (and copying) data.
>
>
>     function pasteHandler(event){
>       var clipboardData, pastedData;
>       var e = event.originalEvent;
>       var matrix;
>
>       clipboardData = e.clipboardData || window.clipboardData;
>       if (!clipboardData) return false;
>
>       pastedData = clipboardData.getData("Text");
>       matrix = tabMatrix(pastedData);
>       if (isMatrix(matrix)) {
>         // Stop data actually being pasted
>         var point = pastePoint(e.target);
>         var matrixHandler = event.data;
>         if (matrixHandler) {
>           e.stopPropagation();
>           e.preventDefault();
>           matrixHandler({"matrix": matrix, "point": point});
>         }
>       }
>     }
>
>
>     --
>     Esteban A. Maringolo
>     _______________________________________________
>     seaside mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>     <http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside>
>
>
>
>
> --
>
>
> ------------------------------------------------------------------------
>
> Gabriel O. Cotelli
> Desarrollo y Tecnología
> Mercap
> Tel: +54 (011) *5352.2372 al 74*
> http://www.mercapsoftware.com
>
> This message is confidential. It may also contain information that is
> privileged or otherwise legally exempt from disclosure. If you have
> received it by mistake please let us know by e-mail immediately and
> delete it from your system; also you shouldn't copy the message nor
> disclose its contents to anyone. Thanks.
> ------------------------------------------------------------------------
>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

--
Esteban A. Maringolo
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: AJAX callback:value: via POST message

Paul DeBruicker
In reply to this post by Esteban A. Maringolo
You can change the

html jQuery ajax


to


html jQuery post


and it should POST the data.  




Esteban A. Maringolo wrote

> Hi,
>
> I'm currently doing a an AJAX call with #callback:value: where the value
> is a stringified JSON I built at client side and which on completion
> returns a script file. But the value payload is passed encoded in the
> URI, and this has a size limit.
>
> Is there a way to do a callback:value: using POST instead of GET?
>
> The call is something like this:
>
> ( html jQuery id: self tableId )
>   on: 'paste'
>   selector: nil
>   data: ( ( html jQuery ajax )
>     callback: [ :json | self pasteMatrix: ( WAJsonParser parse: json ) ]
>       value: ( JSStream on: 'JSON.stringify(arguments[0])' );
>     onComplete: ( html jQuery ajax
>       script: [ :s | self scriptValidatedReloadOn: s ] ) ) asFunction.
>   call: (JSStream on: 'pasteHandler' )
>
>
> And I'd like to have a POST based function that sends the JSON string in
> it's `data` payload instead.
>
> Regards,
>
>
> Appendix A:
>
> `pasteHandler` is a custom function that detects if the contents being
> pasted into a text input are not a single value but instead are values
> copied from an Excel file, in tab separated format, and if so overrides
> the event propagation, creates a matrix (array of arrays), and calls the
> function passed to the `data:` parameter in the event handler.
>
> Because the inputs are presented as separate
> <input>
>  tags within a
> table, that's the only way I found to preserve the convenience of having
> separate inputs, but with the behavior of a single "grid" for pasting
> (and copying) data.
>
>
> function pasteHandler(event){
>   var clipboardData, pastedData;
>   var e = event.originalEvent;
>   var matrix;
>
>   clipboardData = e.clipboardData || window.clipboardData;
>   if (!clipboardData) return false;
>
>   pastedData = clipboardData.getData("Text");
>   matrix = tabMatrix(pastedData);
>   if (isMatrix(matrix)) {
>     // Stop data actually being pasted
>     var point = pastePoint(e.target);
>     var matrixHandler = event.data;
>     if (matrixHandler) {
>       e.stopPropagation();
>       e.preventDefault();
>       matrixHandler({"matrix": matrix, "point": point});
>     }
>   }
> }
>
>
> --
> Esteban A. Maringolo
> _______________________________________________
> seaside mailing list

> seaside@.squeakfoundation

> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside





--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: AJAX callback:value: via POST message

Esteban A. Maringolo
This was the first thing I tried, but the "onComplete:" handler was not
allowed in the options, I then tried some other stuff but caused a full
page response).

Regards!

On 21/06/2018 14:07, Paul DeBruicker wrote:

> You can change the
>
> html jQuery ajax
>
>
> to
>
>
> html jQuery post
>
>
> and it should POST the data.  
>
>
>
>
> Esteban A. Maringolo wrote
>> Hi,
>>
>> I'm currently doing a an AJAX call with #callback:value: where the value
>> is a stringified JSON I built at client side and which on completion
>> returns a script file. But the value payload is passed encoded in the
>> URI, and this has a size limit.
>>
>> Is there a way to do a callback:value: using POST instead of GET?
>>
>> The call is something like this:
>>
>> ( html jQuery id: self tableId )
>>   on: 'paste'
>>   selector: nil
>>   data: ( ( html jQuery ajax )
>>     callback: [ :json | self pasteMatrix: ( WAJsonParser parse: json ) ]
>>       value: ( JSStream on: 'JSON.stringify(arguments[0])' );
>>     onComplete: ( html jQuery ajax
>>       script: [ :s | self scriptValidatedReloadOn: s ] ) ) asFunction.
>>   call: (JSStream on: 'pasteHandler' )
>>
>>
>> And I'd like to have a POST based function that sends the JSON string in
>> it's `data` payload instead.
>>
>> Regards,
>>
>>
>> Appendix A:
>>
>> `pasteHandler` is a custom function that detects if the contents being
>> pasted into a text input are not a single value but instead are values
>> copied from an Excel file, in tab separated format, and if so overrides
>> the event propagation, creates a matrix (array of arrays), and calls the
>> function passed to the `data:` parameter in the event handler.
>>
>> Because the inputs are presented as separate
>> <input>
>>  tags within a
>> table, that's the only way I found to preserve the convenience of having
>> separate inputs, but with the behavior of a single "grid" for pasting
>> (and copying) data.
>>
>>
>> function pasteHandler(event){
>>   var clipboardData, pastedData;
>>   var e = event.originalEvent;
>>   var matrix;
>>
>>   clipboardData = e.clipboardData || window.clipboardData;
>>   if (!clipboardData) return false;
>>
>>   pastedData = clipboardData.getData("Text");
>>   matrix = tabMatrix(pastedData);
>>   if (isMatrix(matrix)) {
>>     // Stop data actually being pasted
>>     var point = pastePoint(e.target);
>>     var matrixHandler = event.data;
>>     if (matrixHandler) {
>>       e.stopPropagation();
>>       e.preventDefault();
>>       matrixHandler({"matrix": matrix, "point": point});
>>     }
>>   }
>> }
>>
>>
>> --
>> Esteban A. Maringolo
>> _______________________________________________
>> seaside mailing list
>
>> seaside@.squeakfoundation
>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Seaside-General-f86180.html
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

--
Esteban A. Maringolo
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside