Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


imgrooot last won the day on May 16 2018

imgrooot had the most liked content!

Community Reputation

1 Neutral

About imgrooot

  • Rank
    Advanced Member

Recent Profile Visitors

2,678 profile views
  1. Wow that was a simple solution. It works now. Here is the update code. All I had to do was add ".reverse()" to the each data. <div id="output"></div> <script> $(document).ready(function(){ $.ajax ({ type: 'GET', url: "https://3rdpartywebsite.com/api/getcustomers", dataType: 'json', success: function(data) { $.each(data.reverse(), function(i, v) { var customerId = v.customerId; var firstName = v.firstName; var lastName = v.lastName; var createdDateTime = v.createdDateTime;
  2. I was hoping for a simpler solutions where someone can edit my code to include the sort by. I've been researching and trying to do it myself but no luck so far. Also I am noticing that the page load time increases every time I submit the record and I retrieve them from the API. It really shouldn't be taking a min to load 20 records from the API. Do you think if I create a pagination that it'll slow the load time? Or you think it's an issue on the API party's end?
  3. I am retrieving data using AJAX. I would like to sort them from newest to oldest date. Currently they show from oldest to newest. How do I do that? <div id="output"></div> <script> $(document).ready(function(){ $.ajax ({ type: 'GET', url: "https://3rdpartywebsite.com/api/getcustomers", dataType: 'json', success: function(data) { $.each(data, function(i, v) { var customerId = v.customerId; var firstName = v.firstName; var lastName = v.lastName; var createdDateTime = v.creat
  4. I have a solution. Apparently I was inputting the wrong label name. Instead of it being "FirstName", it's actually with lowercase "firstName". Here's the new code. <script> $.ajax ({ type: 'GET', url: "https://3rdpartywebsite.com/api/GetCustomers", dataType: 'json', success: function(data) { $.each(data, function(i, v) { $('.output').append(v.firstName); $('.output').append(v.lastName); }); } }); </script> // To access individual record inside the array. console.log(data[0].firstName);
  5. I did that. No more error but nothing is displaying in the .output div. $.each(data, function(i, v) { $('.output').append(v.LastName); });
  6. I am retrieving data from a third party's API using AJAX method. I would like to do two things. 1. Display the data records on a page. 2. Create a pagination on the page to display records more efficiently. I am expecting to retrieve possibly hundreds of records. I can normally do this using PHP but since I am retrieving the records using AJAX, the pagination is gonna be a challenge. First things first is to display the records. Here is my AJAX code. It displays the log data fine. But it doesn't display any data in the "output" div. And it gives this error in the console.
  7. This issue has been resolved. I did not have to do any hack tricks to make it work. The problem was simple. 1. They provided the incorrect URL. 2. All form required fields had to be filled out before submitting. 3. Had to clear my browser's cache before doing a new test. Now it submits the form data to their API just fine.
  8. Yes it is a private API created just for us. Supposedly the only two compatible methods to submit the form are AJAX and CURL. The AJAX code you see is what they provided to submit the form. I will get more clarification from them tomorrow.
  9. "CreateCustomer" would create the customer and return the result message if it's successful or not. The verification will be done manually on their end and they will update this "Customer". At that point I use "GetCustomers" to retrieve that information and find out if it has been verified or not. There is no API key provided. It's strictly submitted through that URL they provided. The form field names are exactly as they wanted. AJAX is one of the methods to submit the form. The other one is CURL but i'm not familiar with that. Now that you mentioned it, yeah this method doesn't see
  10. Not sure if i'm allowed to say the company but they are giving a private access to their API that's not available to others. It's essentially to verify customers. I send the data to their them via AJAX call. Here is the full code. <form id="submit-form" method="post" enctype="multipart/form-data"> <fieldset> <label>Last Name *</label> <input type="text" name="LastName" maxlength="300" placeholder="Last Name" /> </fieldset> <fieldset> <label>First Name *</label>
  11. I just meant that an API integration should be pretty straightforward process instead of having to find certain hacks to try and make it work. This is my first time dealing with an API that's not SDK based. I guess the issue is mainly on their end.
  12. The above code echos an error. Warning: file_get_contents(https://3rdpartywebsite.com/api): failed to open stream: HTTP request failed! HTTP/1.1 411 Length Required in Though I should mention that I am trying to create a customer. So the full url is like this "https://3rdpartywebsite.com/api/createCustomer" Still I shouldn't have to go through all this trouble to make a simple AJAX call to a third party API.
  13. I see. So what would a pure PHP solution look like? My hosting provider is telling me that mod_proxy is already installed on the server. So could it be something else?
  14. The thing is this is not a typical API integration. The third party does not provide any API files to added to the server. The only way to connect to this particular third party's API is through a host url they provided. Here is my original ajax code to submit the form's info to that API. <script> var url = "https://3rdpartywebsite.com/api"; $('#submit-form') .submit(function (e) { $.ajax ({ url: url, type: 'POST', data: new FormData(this), proces
  15. Wow, none of the answers I looked at told me that it's the one receiving the AJAX call are the ones who need to add those headers. As for setting up proxy request, I'm not sure what you mean exactly but I did add a chrome extension allowing CORS to work on my browser. I turned it on and did the ajax call test again. Now I no longer get that error. So it seems to work. I would've assumed that the 3rd party api would be using CORS. Guess I will ask them about it.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.