简体   繁体   中英

How to get JSON data from PHP file NOT using jQuery

I've got array send from php that I'm sending over JSON to javascript file. It works using jquery.GET, but I want to use just javascript. I know there's a way, but I can't find it and I bet there's a folk that knows the answer.

This is my code for jquery:

$.get('loadSomething.php', function(data) {

   var dataSomething = data.something;

       // Then working with the data I received from PHP file

}

I want the same thing but using only javascript.

The underlying object of ajax functionality is called XMLHttpRequest , but browser support especially older ones varies greatly in support of features or even the way you get a hold of this object, see the Browser compatibility table of the MDN page. Generally you don't want to reinvent the whole compatibility mess that JQuery and other frameworks do for you.

This getting started guide should prove itself helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM