Though many of the concepts in this course are still relevant, overall this course does not reflect our current course standards.
Transcript from the "Q&A" Lesson
[00:00:00]
>> Zac Gordon: So, are there any questions before we take a break at this point, in terms of AJAX?
>> Audience Member: Mira, just saying looking for the solution on frontend main JS, which you kinda already showed, right?
>> Zac Gordon: For frontend main for the jQuery one? Yeah, that was what we just went over.
[00:00:25]
>> Audience Member: Right, yeah, so she can catch up on the video there, and then can we make the short code go to the API? I'm not sure what [CROSSTALK] just saying short codes.
>> Zac Gordon: So, there this is a place where, man, I need to give some context to explain what they're asking.
[00:00:45] So, in Wordpress, there are what are called short codes, and these are things that, I forget the exact format of, no, it's not that. In the content editor, let's say you wanted to do a grid that was two columns, right? You can't actually throw in all the and all that stuff there.
[00:01:09] So, there's a format of using what are called shortcodes in WordPress, and you can, in PHP, I think it's something like this. Or another one might be a contact form. So because this is PHP that's generated, you can't just pass it in with the localized script and necessarily expect it to work, because this is gonna fire off a bunch of stuff.
[00:01:34] What you could potentially do I don't know, that would be a little bit tricky. Basically, you would have to get it in the some sort of format that could then be sent via JavaScript. And when I mentioned it very beginning JS widgets this is one of the things I know it sound a short code but they're trying to figure out how do to like, how do we take stuff?
[00:01:54] That's so, dependent on PHP, And make it available in JavaScript. So I need to dig a little bit deeper my short answer is I don't think that's gonna work, but what you can do is try it and just where you see localized script say something like,
>> Zac Gordon: And see what you get.
[00:02:18] I don't My guess is that that is not gonna work, but it may. I'd be curious.
>> Audience Member: And my row was just asking about that rpelacement for a response. It's JS for WP underscore globals, right?
>> Zac Gordon: Yes. It is. It's exactly what we set right here.
>> Audience Member: Instead of the response from the initial load.
[00:02:43]
>> Zac Gordon: Yep for the initial load because we're getting that from here, and we don't get a response back till after we make the jQuery call, the response is going to come inside of that. Sorry let me just pull up.
>> Zac Gordon: Yeah. So, we can't use response until we get the success back, then we could use response.total_likes.
[00:03:05] Before this ajax call is made, we have to depend on the global variables that we set up of total likes and that comment was wrong, so I'll make sure that gets fixed.