cancel
Showing results for 
Search instead for 
Did you mean: 

Need to Form Post from JS(Javascript) View in SAP UI5

0 Kudos
1,115

Hi Experts,

I am very new in SAP UI5.

My requirement is how to post some value in a external URL from SAP UI5 Java script view.

One Scenario:


User came to my application give their id and my application fetch some data from our DB. After that i need to send or form post those data to a external URL. I need to form post.

Please help me on this.

Thanks and Regards,

Amit Basak

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi,

Thanks to replying in my scn thread.It is really help for me.

I have made the solution in the following way.

var forPayment = "";

         $.ajax({

             url : "./xxxx_Payment",

             data :

             {

                 userName : $('#xxx-Name').val(),

             },

             type: 'GET',

             success : function(responseText) {

              var data = 0;

              var mapForm = document.createElement("form");

                 mapForm.target = "Map";

                 mapForm.method = "POST"; // or "post" if appropriate

                 mapForm.action = "PG URL";

                 var mapInput = document.createElement("input");

                 mapInput.type = "hidden";

                 mapInput.name = "msg";

                 mapInput.value = data;

                 mapForm.appendChild(mapInput);

                 document.body.appendChild(mapForm);

                 map = window.open("", "Map", "status=0,title=0,height=600,width=800,scrollbars=1");

             if (map) {

                 mapForm.submit();

             } else {

                 alert('You must allow popups for this map to work.');

             }

Thanks to every one.

Former Member
0 Kudos

Hi Amit

Please marked it as correct answer.

cheers..!!

Answers (5)

Answers (5)

former_member187977
Participant
0 Kudos

Dear Amit,

At line "url : "./xxxx_Payment"," in your code, what does "./xxxx_Payment" signify? Is it same as PG URL mentioned at "mapForm.action = "PG URL";" OR these 2 URLs are different?

thank you !

seventyros

0 Kudos

Hai Amit,

      I Accept the Kapil's Answer, what Kapil says was correct you have to use the Ajax call for taking your parameters to gateway and talk with your payment gateway provider they will provide an code for connection between the system and bank, which you can find the code in their sandbox, up to me most payment gate ways where providing a code in php, java, Asp.net and this payment gateway are happen in server side scripting and when come to javaScript / jQuery are client side scripting. and my suggestion was you have to decide your server side scripting.


Thank you,

Bharanidaran Venkatachalam

Former Member
0 Kudos

Hi Amit,,

I understood your requirement and than can be done by the way as I told you.you can call a url through and can pass parameter through data of ajax.

That data can be accessed though  parameter name where you called that URL.

Thanks

Kapil

Former Member
0 Kudos

HI Amit,

Through ajax call you can pass parameter from your view to server side JS.

var URL = '';

         

            jQuery.ajax({

                url: jURL,

                //TYPE: 'PUT' ,

                data: {

                    "cmd": "xyz",

                  

                },

                method: 'GET',

                dataType: 'text',

            });

or

var URL = 'url?parameter='+param1;

           

            jQuery.ajax({

                url: jURL,

                //TYPE: 'PUT' ,

                 method: 'GET',

                dataType: 'text',

            });

Many thanks

Kapil Jain

0 Kudos

Hi Kapil

Thanks for your reply.

But my problem is I want to open a new url in the web browser using that form post.I have to pass some parameters and that parameter will be appear on that page(like online payment.In this scenario we have to pass the payment amount and some others value to the payment gateway and in the payment gateway will show my passing parameter values.

Thanks and Regards,

Amit Basak

SergioG_TX
Active Contributor
0 Kudos

HI Amit,

if this is just for testing purposes you could use a free tool such as google postman. for a web application you may use jquery, or if you are using sapui5 you could use the sapui5 library to perform posts to HANA. it depends on the scenario but it should be a simple ajax call doing an HTTP POST method. I suggest you google ajax post on jquery that is a very simple approach.

0 Kudos

Hi Sergio,

Thanks for your reply.This is not testing purpose.One of our client requirement is to implement online transaction from UI5.

So that i need to post some data to the gateway URL and I need to open the URL in the new window.And the passing parameter values will show in the gateway URL.

Thanks and Regards,

Amit Basak