Chapters
33 Chapters
|
3:02:08
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.2.0
Subscribe to download the code!Compatible PHP versions: ^7.2.0
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
19.
Old-School AJAX HTML
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses an older version of Symfony... but since it's a JavaScript tutorial, the concepts are still ? valid!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.2.0",
"symfony/symfony": "3.1.*", // v3.1.10
"twig/twig": "2.10.*", // v2.10.0
"doctrine/orm": "^2.5", // v2.7.1
"doctrine/doctrine-bundle": "^1.6", // 1.10.3
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
"symfony/swiftmailer-bundle": "^2.3", // v2.4.0
"symfony/monolog-bundle": "^2.8", // 2.12.0
"symfony/polyfill-apcu": "^1.0", // v1.2.0
"sensio/distribution-bundle": "^5.0", // v5.0.22
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.16
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"friendsofsymfony/user-bundle": "~2.0@dev", // dev-master
"doctrine/doctrine-fixtures-bundle": "~2.3", // v2.4.1
"doctrine/doctrine-migrations-bundle": "^1.2", // v1.2.1
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"friendsofsymfony/jsrouting-bundle": "^1.6" // 1.6.0
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.1
"symfony/phpunit-bridge": "^3.0" // v3.1.6
}
}
6 Comments
I'm getting a double post to the delete and lift end points.
Can someone help me fix this?
Hey Will T.!
Oh no! Let's see if we can figure this out :). The fact that you're getting a double post to both the delete and lift endpoints makes me think that, somehow, your JavaScript click and submit listeners are being executed multiple times. But to make sure I'm not mistaking things, when you click to delete, you see 2 AJAX requests in your network tools, correct? Oh, and if that is correct, in the network tools in your browser, one of the columns in the network tools next to the request should be "initiator" (it may say something like "someFile.js:6"). Are both of the "initiators" identical or are they different?
Anyways, let's do some debugging! At the top of RepLogApp.js - (if you go to https://symfonycasts.com/screencast/javascript/old-school-ajax-html#codeblock-94f1aed6fd - and expand that code block to full, I'm talking about lines 4-20) we initialize the listeners. I'd add a
console.log('init')to that function. In theory, it should only be called once. But it sounds almost like it's called twice in your case. And the answer will help us debug.Let me know what you find!
Cheers!
When LiftController.php is getting changed shouldn't we leave in
'repLog' => $repLogwith the render?Hey @Daniel
I don't fully get your question. Could you tell to which part of video you are talking about?
Cheers!
Will the following code make more sense to update the total weight after success ajax call? I feel really weird to use the calculateTotalWeight method in the ReplogApp object.
Hey Yan,
But we do the same in the screencast, just move this code you mentioned (finding ".js-total-weight" element and calling calculateTotalWeight() method) to the separate method which is called updateTotalWeightLifted() - we use it in a few places: handleNewFormSubmit() and handleRepLogDelete() methods, so we get rid of code duplication this way.
Cheers!
"Houston: no signs of life"
Start the conversation!