on 06-23-2014 9:11 AM
Hello,
I try to use your ZCL_JSON_HANDLER () in combination of a complex json string which contain parameters and a table. When I break in my function module I see that the function module accepted the parameters and have an empty table.
Can you tell me why the table is not filled in the function module?
This is the source I use:
createContent : function(oController) {
var inputParametersPss = {IV_PROCESS: "TEST",
IV_EVENT : "TEST",
IV_WORK_ITEM : "",
IV_ROLE : "TEST",
IV_OBJECT : "TEST",
IT_FORM_FIELD_VALUES:[{
fieldindex : 0,
fieldname : "test",
fieldvalue : "a"
}],
IT_ATTACHMENTS:[]
};
var oModel_test = new sap.ui.model.json.JSONModel();
// oModel_test.setData(data_test);
$.ajax({
url : "/entrada/json/zctr_entrada_pss_event_trigger?$format=json",
type: "POST", //or POST?
dataType: "json",
data : inputParametersPss,
success: function(data){
var jsonString = jQuery.parseJSON( data.OUTPUT );
data_test = jsonString;
oModel_test.setData(jsonString);
alert(oModel_test.getJSON());
},
error: function(){alert("error")}
});
return new sap.m.Page({
title: "Title",
content: [
]
});
}
Import paramaters function module:
Kind Regards,
Richard
Hi Richard,
Using Jquery.ajax like in the example, jquery will try to convert the data to a query string, which is not obviously what we want.
In "data" there must be a correctly formed JSON string. You may try something like the following inside the $.ajax:
data: JSON.stringify( inputParametersPss ),
contentType: "application/json",
Setting a string in "data" should enconde it correctly and prevent jquery from trying to convert the data to a query string. If you want to be sure that data is not processed you may add:
processData: false,
To the list of settings in the jquery call.
It is important that you set correctly the content type of the posted data. Otherwise, jquery sends it as a urlencoded string and this may cause confusion in the adaptor.
Thanks for asking.
Hope this helps,
César.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.