0

This is how the json I get from my page send when I clicked post, I throw a different URL.

That piece of data should like to come to look like this:

api.quickpay.net/subscriptions?currency=dkk&order_id=testworld&description=MB: 6-testworld

But when I get my json back watching it like this:

{"Prices":220,"HiddenIdMedlemskab":6,"ordre_id":"6-8315042016","currency":"DKK","description":"MB: 6-8315042016"}

The json should I have shed into a url that I added earlier.

My jquery code looks like this:

$.ajax({                
    type: 'post',
    url: '/Medlem/medlemskabet',
    dataType: 'json',
    data: JSON.stringify(requestData),
    contentType: 'application/json; charset=utf-8',
    async: true,
    processData: false
});

Over on my url /Medlem/medlemskabet That gets the dates that I need for my json to specify package price orderid etc

So my question is How do I tag my json about throwing it over to the api URL and throws it into their system.

I've built since the MVC C #

J. Petersen
  • 101
  • 1
  • 9

1 Answers1

0

You can pass the JSON object as an argument to $.get(), and jQuery will convert the properties into URL parameters.

$.ajax({                
    type: 'post',
    url: '/Medlem/medlemskabet',
    dataType: 'json',
    data: JSON.stringify(requestData),
    contentType: 'application/json; charset=utf-8',
    async: true,
    processData: false,
    success: function(response) {
        $.get('api.quickpay.net/subscriptions', response);
    }
});
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • I don't understand what that means. My answer doesn't show anything, it just calls the API. – Barmar Mar 25 '16 at 23:42
  • its give me a error on "requestData", its say: Uncaugth rederenceError: requestData is not defined – J. Petersen Mar 25 '16 at 23:48
  • I took that from the code in your question. I thought that part was working, and it returns the JSON that you showed. – Barmar Mar 25 '16 at 23:50
  • It does this too but I just saw the error by going into the console and look. This error happens first when I clicked on submit – J. Petersen Mar 25 '16 at 23:52
  • i try to this here: http://tech.quickpay.net/api/services/?scope=merchant#POST-subscriptions---format- – J. Petersen Mar 25 '16 at 23:52
  • You need to fix the part of the code that sets `requestData` before it calls `$.ajax`. – Barmar Mar 25 '16 at 23:55
  • How do you think I should do it ?, this is the first time I, like, really work with json to javascript? and as well api – J. Petersen Mar 25 '16 at 23:58
  • I really don't understand what you're asking. You just need to fill in `requestData` from your application's input before making the AJAX call. Without seeing more of the code, I can't be any clearer. – Barmar Mar 25 '16 at 23:59