I have a problem in my code which is probably a jQuery issue but I can’t figure out what it is. When I upload a product and try to select the parent category my browser freezes (like it’s consuming a lot of memory). Also the child select menu is showing the parent titles. When I edit a product the parent and the child is showing correctly and in the child select option menu I can make changes but when I try this with the parent select it freezes my browser again…
This is the product upload section where the user can select the category:
Can you narrow it down to where in the code is causing the freeze, using something like console.log() for example? I don’t do a lot of JS and there may be more elegant ways to debug.
I wonder if it’s just because, if the parameter is not passed, you set it to an empty string. Could you set it to something else that definitely won’t be in the ID field instead of an empty string?
Well, I meant any value that will not match an id in your PHP code, so won’t set a selection when there should not be one. So, if “*” isn’t a valid ID, then that would do it.
Alternatively you could modify the PHP code to check whether there’s a $_POST['selected'] before you use it, which would probably be a good idea in any case.
What happens if you call your PHP code from a short html form and bypass the Ajax, just to see if it’s doing anything unexpected, or giving an error message?
I’ve never seen an Ajax call combined with ob_start() and ob_get_clean(), does it work any better if you drop those?