Solved

Convert jquery ajax call to pure javascript

Posted on 2016-10-25
3
55 Views
Last Modified: 2016-11-01
HI,
I am currently using jquery to make an ajax call :
$.ajax({
        url: url,
        type: 'POST',
        contentType: 'application/json',
        headers: {
            'X-hfh': this.data
        },
        dataType: 'json',
        success: function(result) {
            $.each(result, function(idx, item) {
                mybuddyList.push({
                    DisplayText: item.name,
                    JID: item.id,
                    ImageURL: item.profileImage
                });
            });
        },
        error: function() {
            console.log("Error");
        }
    });

Open in new window

I want to get rid of jquery and use only javascript to achieve the same.
How do i do it.

Thanks
0
Comment
Question by:Rohit Bajaj
3 Comments
 
LVL 21

Accepted Solution

by:
Kim Walker earned 300 total points
Comment Utility
There are entire books written about how to do ajax without jQuery. If you insist on doing it without using jQuery, I would suggest Head First Ajax by O'Reilly. But I highly recommend using jQuery.
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 150 total points
Comment Utility
How do i do it.
Open for example this one : https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js

Go to line 7116 to 8101 to see what jQuery do.
You need to cleanup the code.
If you find any jQuery use, check if you can do simpler or just do a new search inside the file.

It's not a simpler job as it required to have lot of time maybe it's your case.
0
 
LVL 42

Assisted Solution

by:Rob Jurd, EE MVE
Rob Jurd, EE MVE earned 50 total points
Comment Utility
Given jQuery IS JavaScript this seems like an odd request... There's no reason to ever do this unless this is for an assignment?

https://www.experts-exchange.com/articles/12264/Javascript-Frameworks-what-are-they.html
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now