Solved

Convert jquery ajax call to pure javascript

Posted on 2016-10-25
3
94 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 22

Accepted Solution

by:
Kim Walker earned 300 total points
ID: 41859718
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
ID: 41865811
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 43

Assisted Solution

by:Rob
Rob earned 50 total points
ID: 41866527
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

790 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