Solved

Convert jquery ajax call to pure javascript

Posted on 2016-10-25
3
99 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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)

733 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