Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function ($) {
- var target = document.getElementById('search-result');
- var config = {
- childList: true
- };
- //note this observe method
- observer.observe(target, config);
- // console.log("registered");
- });
- var success = function(data) {
- loc = getUrlParameter('search_location').split(', ')[0];
- if (typeof category !== 'undefined' || category !== null) {
- loc.length > 0 ? loc += " közelében" : loc = "";
- title.innerText = data[0] + " magántanár " + loc;
- desc.innerText = data[1];
- }
- };
- var observer = new MutationObserver(function (mutationRecords, observer) {
- mutationRecords.forEach(function (mutation) {
- title = document.getElementById("search-cat-title");
- desc = document.getElementById("search-cat-desc");
- window.category = CASE27_Explore_Settings.ListingTypes.tanarok.filters.job_category;
- Array.isArray(category) ? category = category[0] : category = category;
- get_category_name(category, success);
- });
- });
- function getUrlParameter(name) {
- name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
- var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
- var results = regex.exec(location.search);
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
- };
- function get_category_name(category, successCallback, errorCallback) {
- // We'll pass this variable to the PHP function seo_ajax_request
- // This does the ajax request
- jQuery.ajax({
- url: seo_ajax_obj.ajaxurl, // or example_ajax_obj.ajaxurl if using on frontend
- data: {
- 'action': 'seo_ajax_request',
- 'category' : category
- },
- success:function(data) {
- // This outputs the result of the ajax request
- successCallback(JSON.parse(data));
- },
- error: function(errorThrown){
- errorCallback(errorThrown);
- }
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement