问题是当我通过使用短代码得到结果并且我把它放在我的页面中时,即使内容在这里也没有显示。
首先是我使用ajax的函数:
function ma_fonction_js()
{
jQuery.ajax({
url: mon_script_ajax.ajaxurl,
data: ({action : 'ma_fonction_ajax'}),
success: function(response) {
/* the problem is here when i try to add my response in my tag html*/
jQuery("#etat_button").append(response);
}
});
}

这是我在wordpress(functions.php)文件中的函数php:
<?php
function ma_fonction() {
wp_enqueue_script( 'function', get_template_directory_uri().'/etat_button.js', 'jquery', true);
wp_localize_script( 'function', 'mon_script_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
}
add_action('template_redirect', 'ma_fonction');
add_action("wp_ajax_nopriv_ma_fonction_ajax", "ma_fonction_ajax");
add_action("wp_ajax_ma_fonction_ajax", "ma_fonction_ajax");
function ma_fonction_ajax()
{
echo "<div id='teste' style='border:2px solid black;'>". do_shortcode('[dopbsp id=4 lang="fr"]') ."</div>";
die();
}
?>
&#13;
在我的页面中我得到了这个:
<div style="border:2px solid black;" id="teste">
<link href="http://localhost/daramjad/public_html/wp-content/plugins/dopbsp/templates/default/css/jquery.dop.frontend.BSPCalendar.css" type="text/css" rel="stylesheet">
<script type="text/JavaScript">
jQuery(document).ready(function(){
jQuery("#DOPBSPCalendar4").DOPBSPCalendar({"calendar":{"data":{"bookingStop":0,"dateType":1,"language":"fr","pluginURL":"http:\/\/localhost\/daramjad\/public_html\/wp-content\/plugins\/dopbsp\/","maxYear":2014,"reinitialize":false,"view":false},"text":{"addMonth":"Add month view","available":"available","availableMultiple":"available","booked":"booked","nextMonth":"Next month","previousMonth":"Previous month","removeMonth":"Remove month view","unavailable":"unavailable"}},"cart":{"data":{"enabled":false},"text":{"isEmpty":"Cart is empty.","title":"Cart"}},"coupons":{"data":{"coupon":null,"id":"0"},"text":{"byDay":"day","byHour":"hour","code":"Enter code","title":"Coupons","use":"Use coupon","verify":"Verify code","verifyError":"The coupon code is invalid. Please enter another one.","verifySuccess":"The coupon code is valid."}},"currency":{"data":{"code":"EUR","position":"before","sign":"&#8364;","text":[]}},"days":{"data":{"available":[true,true,true,true,true,true,true],"first":1,"morningCheckOut":false,"multipleSelect":true},"text":{"names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"shortNames":["Su","Mo","Tu","We","Th","Fr","Sa"]}},"deposit":{"data":{"deposit":0,"type":"percent"},"text":{"title":"Deposit"}},"discounts":{"data":{"discount":[],"id":"0"},"text":{"byDay":"day","byHour":"hour","title":"Discount"}},"extras":{"data":{"extra":[{"id":"4","extra_id":"2","position":"1","multiple_select":"true","required":"true","translation":"R\u00e9server :","group_items":[{"id":"16","group_id":"4","position":"1","operation":"+","price":"5000","price_type":"fixed","price_by":"period","translation":" Tout le riad"},{"id":"10","group_id":"4","position":"2","operation":"+","price":"75","price_type":"fixed","price_by":"period","translation":"Corail"},{"id":"11","group_id":"4","position":"3","operation":"+","price":"85","price_type":"fixed","price_by":"period","translation":"Topaze"},{"id":"12","group_id":"4","position":"4","operation":"+","price":"85","price_type":"fixed","price_by":"period","translation":"Rubis"},{"id":"13","group_id":"4","position":"5","operation":"+","price":"100","price_type":"fixed","price_by":"period","translation":"Cornaline"},{"id":"14","group_id":"4","position":"6","operation":"+","price":"100","price_type":"fixed","price_by":"period","translation":"Rose des sables"}]}],"id":"2"},"text":{"byDay":"day","byHour":"hour","invalid":"Select an option from","title":"Extras"}},"fees":{"data":{"fees":[]},"text":{"byDay":"day","byHour":"hour","included":"Included in price"}},"form":{"data":{"form":[{"id":"1","form_id":"1","type":"text","position":"1","multiple_select":"false","allowed_characters":"","size":"0","is_email":"false","required":"true","translation":"Pr\u00e9nom"},{"id":"2","form_id":"1","type":"text","position":"2","multiple_select":"false","allowed_characters":"","size":"0","is_email":"false","required":"true","translation":"Nom"},{"id":"3","form_id":"1","type":"text","position":"3","multiple_select":"false","allowed_characters":"","size":"0","is_email":"true","required":"true","translation":"Email"},{"id":"20","form_id":"1","type":"text","position":"4","multiple_select":"false","allowed_characters":"","size":"0","is_email":"true","required":"true","translation":"confirmer votre adresse mail"},{"id":"4","form_id":"1","type":"text","position":"5","multiple_select":"false","allowed_characters":"0123456789+-().","size":"0","is_email":"false","required":"true","translation":"T\u00e9l\u00e9phone"},{"id":"23","form_id":"1","type":"text","position":"6","multiple_select":"false","allowed_characters":"","size":"0","is_email":"false","required":"false","translation":"Nationalit\u00e9"},{"id":"5","form_id":"1","type":"textarea","position":"7","multiple_select":"false","allowed_characters":"","size":"0","is_email":"false","required":"true","translation":"Exigences sp\u00e9ciales"},{"id":"16","form_id":"1","type":"select","position":"8","multiple_select":"false","allowed_characters":"","size":"0","is_email":"false","required":"true","translation":"Nombre de chambres","options":[{"id":"18","field_id":"16","position":"2","translation":"1"},{"id":"19","field_id":"16","position":"3","translation":"2"},{"id":"20","field_id":"16","position":"4","translation":"3"},{"id":"21","field_id":"16","position":"5","translation":"4"},{"id":"22","field_id":"16","position":"6","translation":"5"}]},{"id":"24","form_id":"1","type":"select","position":"9","multiple_select":"false","allowed_characters":"","size":"0","is_email":"false","required":"true","translation":"Nombre d'adultes","options":[{"id":"25","field_id":"24","position":"2","translation":"1"},{"id":"24","field_id":"24","position":"3","translation":"2"},{"id":"26","field_id":"24","position":"4","translation":"3"},{"id":"27","field_id":"24","position":"5","translation":"4"}]},{"id":"14","form_id":"1","type":"select","position":"10","multiple_select":"false","allowed_characters":"","size":"0","is_email":"false","required":"true","translation":"Nombre d'enfants","options":[{"id":"10","field_id":"14","position":"2","translation":"0"},{"id":"11","field_id":"14","position":"3","translation":"1"},{"id":"12","field_id":"14","position":"4","translation":"2"},{"id":"13","field_id":"14","position":"5","translation":"3"}]}],"id":"1"},"text":{"invalidEmail":"is invalid. Please enter a valid email.","required":"is required.","title":"Contact information"}},"hours":{"data":{"addLastHourToTotalPrice":true,"ampm":false,"definitions":[{"value":"00:00"}],"enabled":false,"info":true,"interval":false,"multipleSelect":true},"text":[]},"ID":"4","months":{"data":{"no":"1"},"text":{"names":["January","February","March","April","May","June","July","August","September","October","November","December"],"shortNames":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}},"order":{"data":{"paymentArrival":true,"paymentArrivalWithApproval":false,"paymentGateways":[],"redirect":"","termsAndConditions":true,"termsAndConditionsLink":"http:\/\/www.daramjad.com\/conditions-generales\/"},"text":{"book":"Book now","paymentArrival":"Pay on arrival (need to be approved)","paymentArrivalWithApproval":"Pay on arrival (instant booking)","paymentArrivalSuccess":"Your request has been successfully sent. Please wait for approval.","paymentArrivalWithApprovalSuccess":"Your request has been successfully received. We are waiting you!","paymentMethod":"Payment method","paymentMethodNone":"None","paymentMethodArrival":"On arrival","paymentMethodTransactionID":"Transaction ID","status":"Status","statusApproved":"Approved","statusPending":"Pending","success":"Add reservation","termsAndConditions":"I accept to agree to the Terms & Conditions.","termsAndConditionsInvalid":"You must agree with our Terms & Conditions to continue.","title":"Order","unavailable":"The period you selected is not available anymore. The calendar will refresh to update the schedule.","unavailableCoupon":"The coupon you entered is not available anymore."}},"reservation":{"data":[],"text":{"price":"Price","priceTotal":"Total","selectDays":"Please select the days from calendar.","selectHours":"Please select the days and hours from calendar.","title":"R\u00e9servation"}},"rules":{"data":{"rule":null,"id":"0"},"text":{"maxTimeLapseDaysWarning":"You can book only a maximum number of %d days.","maxTimeLapseHoursWarning":"You can book only a maximum number of %d hours.","minTimeLapseDaysWarning":"You need to book a minimum number of %d days.","minTimeLapseHoursWarning":"You need to book a minimum number of %d hours."}},"search":{"data":[],"text":{"checkIn":"Check in","checkOut":"Check out","hourEnd":"Finish at","hourStart":"Start at","noItems":"No book items","noServices":"There are no services available for the period you selected.","noServicesSplitGroup":"You cannot add divided groups to a reservation.","title":"Search"}},"sidebar":{"data":{"noItems":true,"positions":{"search":{"column":1,"row":1},"extras":{"column":1,"row":2},"coupons":{"column":1,"row":3},"reservation":{"column":2,"row":1},"cart":{"column":2,"row":2},"form":{"column":2,"row":3},"order":{"column":2,"row":4}},"style":"1"},"text":[]},"woocommerce":{"data":{"enabled":false,"product_id":0},"text":{"none":"No reservation","reservation":"!"}}});
});
</script>
<div id="DOPBSPCalendar-info-message4" class="DOPBSPCalendar-info-message">
<div class="dopbsp-icon"></div>
<div class="dopbsp-text"></div>
<div class="dopbsp-timer"></div>
<a class="dopbsp-close" onclick="jQuery('#DOPBSPCalendar-info-message4').stop(true, true).fadeOut(300)" href="javascript:void(0)"></a>
</div>
<div id="DOPBSPCalendar4" class="DOPBSPCalendar-wrapper notranslate"><a href="http://localhost/daramjad/public_html/wp-admin/admin-ajax.php"></a></div>
</div>
&#13;