-
AuthorPosts
-
April 3, 2019 at 9:32 am #1086440
Hi,
I setup a custom template for one page, because we need some kind of configurator which gets data from database.
I have three files:
1. Template for wordpress (I copied the page.php for the child theme)
2. configuration.php
3. load_data.phpThe configuration.php is included in the template.
At the end of the configuration.php I load the data.php by ajax for the query of what is selected and what should be shown.My code works, because when I run it at my localhost everything is fine. I think its the ajax part, which cannot load the right way to call the load_data.php.
I also tried to add the script in the functions.php to load it in the footer (and I also replaced $ with jQuery) – didn’t workCode configuration.php:
https://pastebin.com/AUF2XetVCode load_data.php:
https://pastebin.com/XVYtBzBvajax should load in the footer of the configuration.php, but that couldn’t work, because the footer is loaded seperatly. I also tried to adjust the footer.php for my child-theme. But that doesn’t work either.
This is the ajax code to call the load_data.php:<script> $(document).ready(function(){ $('#brand').change(function(){ var brand_id = $(this).val(); $.ajax({ url:"load_data.php", method:"POST", data:{brand_id:brand_id}, success:function(data){ $('#show_model').html(data); } }); }); }); </script>
I also tried to add this snippet in the functions.php (also replaced $ with jQuery) but my selection doesn’t work.
Since it works on my localhost the problem has to be the position of the ajax script.
I am not a developer and I spent a lot of time to make this work :), so please keep answers as simple as possible to understand :). I just need to find a workaround.Dropbox download for video snippets (screen records):
https://www.dropbox.com/sh/702tjj78gkm9xeg/AABrQVvEXTCFAKueCCmB545-a?dl=0
(design hasn’t been made yet)localhost.mp4 = how it should work
internal_testserver_wordpress.mp4 = how it (doesn’t) work in wordpressKind regards,
LucasApril 7, 2019 at 4:17 pm #1087984Hey CM_Dyn,
Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)
Best regards,
BasilisApril 8, 2019 at 2:06 pm #1088272Hi Basillis,
you just need to tell me where I need to run my ajax script, or am I wrong?
Everything works fine, I get all data from our Database but I cannot do the selection (= run the code from load_data.php), because it seems like my jquery part of the configuration.php isn’t loading at the right file/part…You just need to tell my what I need to do to add my ajax code at the right position in your template :) – this couldnt be that hard and I think I won’t need a freelancer for that.
If I am completely wrong then please just tell me what is necessary to accomplish that (I need no code – just a short explanation).
Thank you and best regards
LucasApril 11, 2019 at 5:15 am #1089382Hi,
Looks like you’re not using WordPress when you tested the code in your localhost. And the sql queries don’t really conform with the structure of a WP database. There is a standard way or method of using AJAX in WordPress. You can learn more about that in the following article.
// https://www.smashingmagazine.com/2011/10/how-to-use-ajax-in-wordpress/
Unfortunately, what you’re trying to create is beyond the scope of support and it’s not something we can help you with. Please hire a freelance developer or contact our partner, Codeable.
Best regards,
IsmaelApril 11, 2019 at 8:53 am #1089460Thank you Ismael. I will try to fix this.
April 12, 2019 at 1:28 am #1089803 -
AuthorPosts
- You must be logged in to reply to this topic.