send data with post method
Posted: Tue Sep 17, 2019 7:13 am
Dear Antonio I have a function attached to a button and I want to send data to the calling program.
function nextstep(){
var id;
var TableData = new Array();
$('#sampleTbl tr').each( function(row, tr){
$id = parseInt($(tr).find('td:eq(0)').text(), 10) + 1; TableData = TableData
+ "Task No."+ $(tr).find('td:eq(0)').text() + ': ' // Task No.
+ aArtNr[$id] + ' ' // Description
+ '\n';
});
window.location ="/booking_new/zusatz.prg?buchung=" + TableData ;
}
This is working and I get the data with ? STRTRAN(AP_Args(), "%20", " ")
How can I send these data that I can get it with hPairs := AP_PostPairs()
--------------------------------------------------------------------------------------
Antonio Linares 08:49 Uhr
use POST instead of GET
Otto 08:50 Uhr
can you please tell me where
I think this comes from js window.location ="/booking_new/zusatz.prg?buchung=" + TableData ;
do I have to make a form first
--------------------------------------------------------------------------------------
Antonio Linares 08:55 Uhr
$.post( "zusatz.prg", { one: "one", two: "two", three: "three", whatever: 123 } )
.done( function( data ) { console.log( 'DONE', data ); $( cResultId ).html( data ); } )
.fail( function( data ) { console.log( 'ERROR', data ); } );
second parameter is a JS object (JSON notation)
one: "one" etc are the pairs that you will get from AP_Postairs()
No need to create a form
You can send whatever you want just using a JS object
(JSON means: JS object notation)
in my case this is an array. can I send an array, too.
Antonio Linares 08:57 Uhr
yes
do you know it there is a sample in sample folder
Antonio Linares 08:58 Uhr
{ values: [ one: "one", two: "two", three: "three" ] }
arrays use [ ... ]
can be nested as in Harbour
always think in JSON terms
whatever data you need to move around... use JSON
$.post() sends the data as POST
________________________________________
Neue Nachrichten
Charly 09:03 Uhr
You can also try $.get(), the same but via GET
function nextstep(){
var id;
var TableData = new Array();
$('#sampleTbl tr').each( function(row, tr){
$id = parseInt($(tr).find('td:eq(0)').text(), 10) + 1; TableData = TableData
+ "Task No."+ $(tr).find('td:eq(0)').text() + ': ' // Task No.
+ aArtNr[$id] + ' ' // Description
+ '\n';
});
window.location ="/booking_new/zusatz.prg?buchung=" + TableData ;
}
This is working and I get the data with ? STRTRAN(AP_Args(), "%20", " ")
How can I send these data that I can get it with hPairs := AP_PostPairs()
--------------------------------------------------------------------------------------
Antonio Linares 08:49 Uhr
use POST instead of GET
Otto 08:50 Uhr
can you please tell me where
I think this comes from js window.location ="/booking_new/zusatz.prg?buchung=" + TableData ;
do I have to make a form first
--------------------------------------------------------------------------------------
Antonio Linares 08:55 Uhr
$.post( "zusatz.prg", { one: "one", two: "two", three: "three", whatever: 123 } )
.done( function( data ) { console.log( 'DONE', data ); $( cResultId ).html( data ); } )
.fail( function( data ) { console.log( 'ERROR', data ); } );
second parameter is a JS object (JSON notation)
one: "one" etc are the pairs that you will get from AP_Postairs()
No need to create a form
You can send whatever you want just using a JS object
(JSON means: JS object notation)
in my case this is an array. can I send an array, too.
Antonio Linares 08:57 Uhr
yes
do you know it there is a sample in sample folder
Antonio Linares 08:58 Uhr
{ values: [ one: "one", two: "two", three: "three" ] }
arrays use [ ... ]
can be nested as in Harbour
always think in JSON terms
whatever data you need to move around... use JSON
$.post() sends the data as POST
________________________________________
Neue Nachrichten
Charly 09:03 Uhr
You can also try $.get(), the same but via GET