I’m lost

service.execute with data

Dear Appery

i want to use javascript to execute a service.. and found following

https://getsatisfaction.com/apperyio/...

and was able to modify as below

i have some difficulty with data section.

new_member.execute({
data: {
'fname_xd': 'testsrv',
'lname_xd': 'testname',
'kname_xd': 'knametest'
},

I'm doing post/insert, but nothing is inserted to database (figure 1). i have tested from API express & service (figure 1, row 82 & 83)

I have tried with double quotes and just data : {'fname_xd': 'testsrv'},
(figure 1, row 84,85,86).

eventually, i would like to generate the data object dynamically (function data_from_form() )

so any insight as to what did i miss or did not understand correctly.

Thank YOU!!!!!

JL

figure 1



this is the full code that i have :

function post_mmbr_data() {

var fncdff = data_from_form(); //function data from form

var onSuccessHandler = function(data) {
if (data) { //GENERATED_KEY is an object in an array
console.log('success return data stringfy :' + JSON.stringify(data));
var gkey = data[0].GENERATED_KEY;
Appery('mmbr_id').val(gkey); //show new mmbr_id
}
};
var onErrorHandler = function(data) {
if (data) { //TODO : more user friendly handling
console.log(JSON.stringify(data));
}
};
console.log('data form form stringfy :' + JSON.stringify(fncdff));
//fncdff = JSON.stringify(fncdff);
new_member.execute({
data: {
"fname_xd":"testsrv",
"lname_xd":"testname",
"kname_xd":"knametest"
},
success: onSuccessHandler,
error: onErrorHandler
})
}

function data_from_form() { //data from form
var df = {};
$("[dsid$='_xd']").each(function() {
var $this = $(this);
var inputName = $this.attr('name'); //
console.log('inputname: ' + inputName);
var inputdata = $this.val(); //
console.log('inputdata: ' + inputdata);
df[inputName] = inputdata;
}); //console.log(df);
return df
}
1 person has
this problem
+1
Reply
  • Hello,

    Unfortunately, any help (and/or debugging) with your custom app code or logic as well as 3rd party Apache Cordova/PhoneGap plugins are not covered by our [Support policy] (https://docs.appery.io/docs/general-s...).
    To get such help, you will need to consider purchasing Advisory Pack: (https://appery.io/services/#Advisory_...)

    Could you please clarify, what exactly does not work there? Does it send data to the server? Please check it in the network tab of your browser
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • I’m happy bc ur helping!
    Dear Serhii

    Good morning to you and thank YOU for your quick response..:)
    This is what i have and tested...

    API Express



    SQL


    from App side

    with request content type : JSON


    network tab



    but none of the data actually inserted to the columns (no error response)

    with request content type : data


    network tab



    network tab : error



    so I'm trying to figure out..

    request content type : JSON, do i have the API Express & SQL setup correctly?

    request content type : data, params looks more like what i have seen before, but get error "can not parse JSON object"

    so my question is which

    1. request content type should i use?
    2. in API express.. should i use request body/ JSON instead of request query parameters? if yes, may i have an example.

    Thank YOU for taking the time to consider this for me!!!
    I'm trying to make this dynamic as possible so that don't have to remap everytime there is an changes in the app..
    Thank YOU once again and have a great day!

    JL

    have read

    https://devcenter2.appery.io/document...
    https://getsatisfaction.com/apperyio/...

    but nothing jumped at me..:(
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • I’m excited
    Dear Serhii

    JUST FYI.. i got it to work..:) thanks to you.. i was testing out the request body/json





    that was the trick!!
    Thank YOU for pointing me to right direction!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited