DEV Community

aakas
aakas

Posted on • Edited on

2 1

Using AJAX for first time.

I had a task assigned to me in a internship. The task was to update the data of the details of applicant when changing the value of the "roll number" of the applicant.

I had never used AJAX before. So, it was new thing for me. At, first I thought it was easy. But, when I started to do it, i couldn't just make it right. I search on google, "how to use a ajax". Many results occured but, I was still not making any progress.

After sometime, I came to realize that I was rushing things. I was focused on result than the process, so I was not making any progress.

So, after realizing that, I focused on the process. I started to learn what actually is ajax, how to use it, what it is used for.

Ajax is use to update the web pages asynchronously by exchanging data with a web server behind the scenes. And it is used as

 $.ajax({
         url: "any url path/",
         type: "POST",
         data:{
               "key":"value",
               "roll": $('#roll').val(),
               "csrfmiddlewaretoken" : "{{csrf_token}}"  // since i am using a jinja template
              }, 
         success: function(response){
               // perform actions here;
              },
          error: function(){
               // perform actions here;
            }
        }
);
Enter fullscreen mode Exit fullscreen mode

The CSRF Token is required while making a POST request.
After learning these things, I tried and tried. There were lot of errors, warnings but i solved them one by one. And finally, the code worked and the result was visible. It felt good to see finally code worked after so many hours of working on it.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay