Это видео недоступно.
Сожалеем об этом.

Working with JSON and PHP

Поделиться
HTML-код
  • Опубликовано: 3 июн 2013
  • Want more? Explore the library at www.codecourse...
    Official site
    www.codecourse...
    Twitter
    / teamcodecourse

Комментарии • 71

  • @mrvaghani
    @mrvaghani 10 лет назад

    Really good example and the narrator has a good understand on how JSON works with PHP.

  • @kennethburla
    @kennethburla 6 лет назад +11

    so json stands for javascript object ........(searching ....) notation haha

  • @-no-handle
    @-no-handle 8 лет назад +24

    When the title says JSON and PHP. Where did Ajex came from? :/

    • @jellybean4049
      @jellybean4049 7 лет назад +2

      So he can call in PhP code without having to reload the page.

    • @aliensofttechnologies1143
      @aliensofttechnologies1143 5 лет назад +1

      @@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.

  • @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.

  • @leonforte5520
    @leonforte5520 10 лет назад +1

    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).

  • @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.

  • @ThaRSGeek
    @ThaRSGeek 11 лет назад

    Yes, good idea so you can understand the possibilities witj JSON and PHP

  • @Ravroid
    @Ravroid 11 лет назад

    Very well-spoken and clear tutorial. Thanks phpacademy!

  • @xAlexPro99x
    @xAlexPro99x 10 лет назад +2

    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

  • @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

  • @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

  • @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)

  • @luchioarelsevilla1247
    @luchioarelsevilla1247 6 лет назад

    its 2018, still amazing lecture.

  • @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.

  • @hanyelmoualed2122
    @hanyelmoualed2122 4 года назад

    It would be much better to handle only reading Json file. Thank you

  •  11 лет назад

    Awesome to see Firefox back again :)

  • @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.

  • @fz8205
    @fz8205 7 лет назад +2

    ALEX IS THE KING OF TEACHERS IN RUclips

  • @Lilleflex
    @Lilleflex 11 лет назад

    Thank you very much!
    I actually found out a few hours later, but thank you anyway :)

  • @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

  • @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

  • @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.

  • @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

  • @Wiejeben
    @Wiejeben 11 лет назад

    Thanks :) Learned a lot from this

  • @ripmusikuk
    @ripmusikuk 10 лет назад

    How would you go about displaying the submission onto the index.php page?

  • @pradeepspace3
    @pradeepspace3 11 лет назад

    again a useful video !
    Thanks !

  • @300Tech
    @300Tech 11 лет назад

    I love this tutorial!

  • @todotutorialeslzc7903
    @todotutorialeslzc7903 6 лет назад

    How do I receive an Array Json objects sent from Javascript?

  • @florianlechleitner501
    @florianlechleitner501 10 лет назад

    really good tutorial, thanks!

  • @chnsonic
    @chnsonic 7 лет назад

    exellent example!

  • @AmrSubZero
    @AmrSubZero 11 лет назад

    great tut, thanks!

  • @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

  • @MarkKevinBesingaWebDev
    @MarkKevinBesingaWebDev 11 лет назад

    hi .. why you need to return false on global.js around 6 - 8 mins. thanks

  • @mangalsharma3732
    @mangalsharma3732 8 лет назад

    plz help geoserver published layer throw php view the layer code json

  • @hrefamid9563
    @hrefamid9563 11 лет назад

    Tip: If you have a 64 bit OS, use Waterfox

  • @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

  • @CzajekTutorialowiec
    @CzajekTutorialowiec 11 лет назад

    03:04 - what does it mean?

  • @combant
    @combant 11 лет назад

    Thanks :)

  • @hrefamid9563
    @hrefamid9563 11 лет назад

    Stopped using google chrome?

  • @momahdy
    @momahdy 9 лет назад

    Must i use ajax ? or i can i just use $.getJSON() ?

  • @Lilleflex
    @Lilleflex 11 лет назад

    What is that text program called?

  • @sairamvarnakavi8293
    @sairamvarnakavi8293 6 лет назад

    It's Awesome

  • @MrVelocityFilms
    @MrVelocityFilms 11 лет назад

    Sublime text

  • @alexandertail1534
    @alexandertail1534 10 лет назад +1

    Хороший урок.

  • @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;

  • @edgarkamdem4620
    @edgarkamdem4620 8 лет назад +1

    Alex I love you :-) ( not in the gay way !)

    • @CristianAlexandruRadu
      @CristianAlexandruRadu 8 лет назад +1

      me too (in the same way) 😂
      but only when he does FREE tutorials!!!

  • @alexandertouchdown8737
    @alexandertouchdown8737 8 лет назад +1

    Javascript Object.....

  • @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. ruclips.net/video/69OXnmbAaLI/видео.html

  • @eliudjhaleel
    @eliudjhaleel 7 лет назад

    (Y)

  • @cotne20031995
    @cotne20031995 11 лет назад

    javascript object ... .... notation
    LOL