How can I process xml file on upload?

I solved my problem with lots and lots of testing things out. Apparently my FormData Object was not correct. Doing these changes to my code worked: $(‘#xml’).on(‘submit’, function(e) { e.preventDefault(); var form_data = new FormData(this); form_data.append(‘action’, ‘calculate_xml’); $.ajax({ url : ajaxurl, type: “POST”, data : form_data, processData: false, cache: false, contentType: false, success:function(response){ $(‘#response’).html(response); }, … Read more

WordPress function to get term or post object by id

get_queried_object() will get the currently queried ‘thing’ from the main query as an object. That could be a WP_Post, WP_Term, or WP_Post_Type (for post type archives) object, but I don’t think that’s quite what you’re asking for and wouldn’t be useful in AJAX. Other than that there isn’t a function for exactly what you’re asking … Read more

How do I set the url to make an ajax request for a html document?

Yes, there is such way: you should pass absolute path in there… Let’s say your JS file is enqueued like this: wp_enqueue_script( ‘my-script’, ‘path-to-js-file.js’… ); Then you should use wp_localize_script and pass the value in there: wp_localize_script( ‘my-script’, ‘MyScriptData’, array( ‘ajax_url’ => site_url(‘/test/file.html’) ) ); Then you can access this value in your JS file … Read more