Bugs with Simple Solution

Bugs with Simple SolutionHello! I’m Andi (My friends mostly call me Kippi). I’m here to share you about my Internship days and some problems i faced since I first started this program, a few major bugs with simple solution. It’s been a month since I’ve started my Internship with Tansah Web & Innovation, and I’ve been through a lot of things since then. I’ve learned many things regarding web development and have been working on a project called Diverlife. I’m currently working on another project with the team.

I work on my first project on the first week of my Internship, and it was quite hard for me, since I had to learn (of course..) new things regarding web developing, and more. I’m still a beginner in this type of work, since I only know basics of web developing from class. I have never even used WordPress and plugins inside it. It may sound quite hard, but i enjoyed the challenge. The hardships I’ve been through gave me even more spirit to push myself to learn new things. So far it is going quite well. In this line of work you will always meet bugs that will always bugs you. What motivates me more is the revelation to solve these bugs with simple solution.

And here are two big problems that keeps bugging me since I couldn’t solve it. Turns out after revelation, got solved with just a few lines of code! Trully ‘Bugs with Simple Solution’

Sorting after ajax call

The first one is a problem i face when i was working on Diverlife project. I wanted to show markers’ data inside the custom info window in descending order from the most diving entry. I use ajax to accomplish it, and it was quite confusing since it was my first time to use ajax in web developing. What’s more confusing is because ajax works asynchronously. Thus the data shown in the custom info window would always come up randomized, even though i’ve already descendingly sorted the data array, and even tried another way to show the data from the most recent one using .prepend() the ajax result to the info window, but nothing helps.

This is where i learned there is one line of code that could make the ajax work synchronously, the “async:false”, and just with this one line of code solved the problem i faced. The data shown in info window was ordered by most recent data, but new problem arose. It may do the work somehow but by making the ajax to work synchonously made the website to froze for a second because it needed to wait the ajax to finish it’s work, and it was quite a bad idea to use “async:false” for a website that process a lot of data, therefore i needed another way to solve the problem.

I found a way to solve it, that is to do a function inside a function, where the outer function works as a function to run the inner function, and the inner function is where the ajax is placed. This function forced the ajax to work sequentially as we want but not making the website to froze.

HTML inside wordpress shortcode

The second one is on a new project. I wanted to create a short-code which has html/js codes in it. I need to put the shortcode in a Divi module, but the codes simply dont want to sit in the module properly. Even though i’ve put the shortcode inside it, but the code always places the html content  in the main body of the web instead. It made me confused for quite a while, and a few lines of code helped this out. It was solved by adding “ob_start()“, then do “ob_get_contents()” and put it inside a variable, and do “ob_end_clean()” and return the variable inside the custom shortcode.


That sums up for now, the two big bugs with simple solution i faced that exercised my brain a lot since i started. I found a lot of new things and learned a lot from it. Working in an internship program has been a lot of fun for me and the team, we always look forward to another brand new day of Internship program! If you would like to participate, do join us in our Coding Internship Programme.