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 AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay