Тёмный

Working with JSON and PHP 

Codecourse
Подписаться 341 тыс.
Просмотров 158 тыс.
50% 1

Want more? Explore the library at www.codecourse...
Official site
www.codecourse...
Twitter
/ teamcodecourse

Опубликовано:

 

6 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 71   
@mrvaghani
@mrvaghani 10 лет назад
Really good example and the narrator has a good understand on how JSON works with PHP.
@delturge
@delturge 4 года назад
Just because the $.ajax method takes a object parameter of dataType: json, does not mean jQuery is actually sending JSON to PHP as it should be (with the correct media type in the Conent-Type header). Unless PHP 7 has been updated to see the application/json media type, I suspect that jQuery is fudging it here, perhaps converting to URL encoded key/value pairs, as it is well documented that the php://input stream wrapper is required to get data sent via an HTTP POST request method, that is not also sent with the following Content-Types: application x-www-form-urlencoded or multipart/form-data.
@delturge
@delturge 4 года назад
The dataType: json property and value of the settings object does not tell jQuery what data format it should send to the server. It merely tells jQuery what kind of data to expect in response! This example is not actually sending JSON to PHP. Read the jQuery API. $.ajax() is converting JSON to URL encoded key/value pairs. If you want to actually send true JSON with $.ajax(), then you should set the contentType: property of the setting / parameter object to 'applicaton/json'. Additionally, you MUST set processData: to false. Relying on jQuery seems less and less like a good idea for web developers to use.
@BehindTheBackground
@BehindTheBackground 11 лет назад
As you can see on 5:12 Alex has a form with the action "add.php". If he wouldnt return "false" and would press the button the browser would open up "add.php" and send the input information. But as we dont want to load a new page, he catches the action and loading the data in the background via ajax.
@kennethburla
@kennethburla 6 лет назад
so json stands for javascript object ........(searching ....) notation haha
@saicharanc7362
@saicharanc7362 5 лет назад
i am about to say this...🤣
@-no-handle
@-no-handle 8 лет назад
When the title says JSON and PHP. Where did Ajex came from? :/
@jellybean4049
@jellybean4049 7 лет назад
So he can call in PhP code without having to reload the page.
@aliensofttechnologies1143
@aliensofttechnologies1143 5 лет назад
@@ahamuffin4747 Stop being mean. People are here to learn.
@delturge
@delturge 4 года назад
@JellybeanGames It's not just so that he can call PHP code without loading the page. That is secondary to the issue. If he were to use standard, synchronous code (say from an HTML form), then there would be no opportunity to send JSON because everything would be sent in the form of URL encoded key/value pairs in the body of the HTTP request. The actual XmlHttpRequest object in JavaScript can do both synchronous and asynchronous HTTP requests. Moreover, it allows you to set the media type value for the all important HTTP Content-Type header. By default, PHP does not see the application/json media type (in the Content-Type header) and $_POST will not contain any data. Just because the $.ajax method takes a object parameter of dataType: json, does not mean jQuery is actually sending JSON to PHP as it should be (with the correct media type in the Conent-Type header). Unless PHP 7 has been updated to see the application/json mediat type, I suspect that jQuery is fudging it here, perhaps converting to URL encoded key/value pairs, as it is well documented that php://input stream wrapper is required to get data sent via the HTTP POST request method that is not also sent with the following Content-Types: application x-www-form-urlencoded or multipart/form-data.
@ThaRSGeek
@ThaRSGeek 11 лет назад
Yes, good idea so you can understand the possibilities witj JSON and PHP
@dealloc
@dealloc 11 лет назад
The MIME type of JSON should be application/json - However if you provide a callback (also known as JSON-P) you use the MIME type of text/javascript, because it's a javascript function that is returned instead of an object.
@leonforte5520
@leonforte5520 10 лет назад
Any reason why console.log() wouldn't work where alert() is? I get the alert working, but nothing is logged in the console (using firefox).
@Ravroid
@Ravroid 11 лет назад
Very well-spoken and clear tutorial. Thanks phpacademy!
@xAlexPro99x
@xAlexPro99x 10 лет назад
wow amazing! you were able to make me understand JSON with PHP! very very good tutorial, subscribed!
@reedjose7624
@reedjose7624 3 года назад
I know it is kind of randomly asking but do anyone know of a good website to watch new tv shows online ?
@deandrekylo1625
@deandrekylo1625 3 года назад
@Reed Jose flixportal :)
@reedjose7624
@reedjose7624 3 года назад
@Deandre Kylo Thank you, signed up and it seems like a nice service :D I really appreciate it !
@deandrekylo1625
@deandrekylo1625 3 года назад
@Reed Jose you are welcome xD
@Crazy113
@Crazy113 11 лет назад
that's a good idea, Alex rocks explaining! I can say he has been my sensei (even thou he doesn't know)
@hodapro3394
@hodapro3394 2 года назад
what if i want to send ajax code thathas json string to php file so i can convert it there into php array how can i do that while i tried but failed many times
@fz8205
@fz8205 7 лет назад
ALEX IS THE KING OF TEACHERS IN RU-vid
@BumbiSit
@BumbiSit 11 лет назад
Please do a proper php socket tutorial. For example how to make a simple live chat using sockets. Its hard to find a good and easy to understand tutorial
@luchioarelsevilla1247
@luchioarelsevilla1247 6 лет назад
its 2018, still amazing lecture.
@devWaleed
@devWaleed 11 лет назад
Alex, its time for an introduction to Web-sockets, I and others with me are thinking of using Web-sockets for Chat application and other social plugins. It would be great if you do a tutorial on this, Or a simple installation and setup guide would be enough too...TY
@camera-support-rentals
@camera-support-rentals 5 лет назад
how do you json_encode a URL? I am having problems with the backslash. If I encode this to json " echo json_encode("foo//bar) " I get this "foo\/\/bar" in json. How do I escape the // so it encodes correctly to json? thanks and I love your tutorials. Jon
@hanyelmoualed2122
@hanyelmoualed2122 4 года назад
It would be much better to handle only reading Json file. Thank you
@JaxCavalera
@JaxCavalera 9 лет назад
I tried using the new .done instead of success and nothing works. my echo from 9:55 is showing in the loaded page at the top which doesn't happen in the example for some reason and my console is empty even though i'm doing a console.log(data); inside the done anonymous function.
11 лет назад
Awesome to see Firefox back again :)
@amirrahman9240
@amirrahman9240 8 лет назад
good and simple tutorial easy to understand !! super like (y) now i can understand where json usefull in after searching a while thanks bro
@Lilleflex
@Lilleflex 11 лет назад
Thank you very much! I actually found out a few hours later, but thank you anyway :)
@ShieldDevs
@ShieldDevs 10 лет назад
Hey Alex, nice video. I was watching this as a reference and I noticed that you are using the the 'success' method for success, but that has now been replaced with the 'done' function since jQuery 1.8; So I think you should update the video so that beginners might not experience problems.
@kingkakig
@kingkakig 6 лет назад
How is it possible to encode Hebrew? I was trying to pass php arrays into JavaScript arrays by json_encode. At first it worked but later stopped and showed error. I don’t know why. The Hebrew letters were translated into a series of numbers and letters in the beginning.
@hrefamid9563
@hrefamid9563 11 лет назад
Tip: If you have a 64 bit OS, use Waterfox
@kitizhi
@kitizhi 9 лет назад
For reason my global.js isn't being picked up and the ajax isn't working even though I referenced it in the index.php
@todotutorialeslzc7903
@todotutorialeslzc7903 6 лет назад
How do I receive an Array Json objects sent from Javascript?
@Wiejeben
@Wiejeben 11 лет назад
Thanks :) Learned a lot from this
@300Tech
@300Tech 11 лет назад
I love this tutorial!
@florianlechleitner501
@florianlechleitner501 10 лет назад
really good tutorial, thanks!
@chnsonic
@chnsonic 7 лет назад
exellent example!
@pradeepspace3
@pradeepspace3 11 лет назад
again a useful video ! Thanks !
@ripmusikuk
@ripmusikuk 11 лет назад
How would you go about displaying the submission onto the index.php page?
@MarkKevinBesingaWebDev
@MarkKevinBesingaWebDev 11 лет назад
hi .. why you need to return false on global.js around 6 - 8 mins. thanks
@AmrSubZero
@AmrSubZero 11 лет назад
great tut, thanks!
@mangalsharma3732
@mangalsharma3732 8 лет назад
plz help geoserver published layer throw php view the layer code json
@PauliusGe
@PauliusGe 11 лет назад
Hi, I have a question about header. I've seen people using content-type application/json . Is there really any difference?
@LEXJEED
@LEXJEED 11 лет назад
good , thank lot
@combant
@combant 11 лет назад
Thanks :)
@hrefamid9563
@hrefamid9563 11 лет назад
Stopped using google chrome?
@MrVelocityFilms
@MrVelocityFilms 11 лет назад
Sublime text
@sairamvarnakavi8293
@sairamvarnakavi8293 6 лет назад
It's Awesome
@Lilleflex
@Lilleflex 11 лет назад
What is that text program called?
@momahdy
@momahdy 9 лет назад
Must i use ajax ? or i can i just use $.getJSON() ?
@aiarcadecode
@aiarcadecode 9 лет назад
+Mohamed El Mahdy You surely can ))
@CzajekTutorialowiec
@CzajekTutorialowiec 11 лет назад
03:04 - what does it mean?
@alexandertail1534
@alexandertail1534 10 лет назад
Хороший урок.
@martinkaspar5095
@martinkaspar5095 6 лет назад
hello dear developer, good evening. Want to work with Json - i i want to translate the following overopass-turbo request [out:csv(::id,::type,"name","addr:postcode","addr:city","addr:street","addr:housenumber","website"," contact:email=*")][timeout:600]; {{geocodeArea:Schweiz}}->.a; ( node(area.a)[amenity=hospital]; way(area.a)[amenity=hospital]; rel(area.a)[amenity=hospital];); out;
@BumbiSit
@BumbiSit 11 лет назад
Well, of course i would need some JS for that, but still, mainly using sockets and socket servers. Just some tutorial that has a good explanation. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-69OXnmbAaLI.html
@edgarkamdem4620
@edgarkamdem4620 8 лет назад
Alex I love you :-) ( not in the gay way !)
@CristianAlexandruRadu
@CristianAlexandruRadu 8 лет назад
me too (in the same way) 😂 but only when he does FREE tutorials!!!
@eliudjhaleel
@eliudjhaleel 7 лет назад
(Y)
@alexandertouchdown8737
@alexandertouchdown8737 8 лет назад
Javascript Object.....
@alexandertouchdown8737
@alexandertouchdown8737 8 лет назад
..............
@alexandertouchdown8737
@alexandertouchdown8737 8 лет назад
Notation
@cotne20031995
@cotne20031995 11 лет назад
javascript object ... .... notation LOL
Далее
Learn JSON in 10 Minutes
12:00
Просмотров 3,2 млн
НЕДОВОЛЬНА УСЛУГОЙ #shorts
00:27
Просмотров 32 тыс.
PHP REST API From Scratch [1] - Database & Read
32:18
Просмотров 511 тыс.
JSON and AJAX Tutorial: With Real Examples
40:45
Просмотров 1,8 млн
Reading JSON with jQuery
9:29
Просмотров 164 тыс.
JSON Crash Course
24:49
Просмотров 1 млн