我需要你帮忙。我在key=13
被命中时运行了一个函数,并且该函数正在调用 ajax,但是之后 ajax 函数并没有停止,它一直在工作,所以我需要知道如何在一次之后停止它。这里有一些代码:
$(document).ready(function()
{
var editor = CKEDITOR.replace('articletext', {
toolbar: [
{name: 'basicstyles', items: ['Bold', 'Italic', 'RemoveFormat']},
{name: 'document', items: ['Source', '-', 'NewPage', 'Preview', '-', 'Templates']}, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups.
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'], // Defines toolbar group without name.
]
});
editor.on("key", function(event) {
//alert(event.data.keyCode);
if (event.data.keyCode===13)
{
this.document.on("keyup", ck_jq);
}
});
});
function ck_jq()
{
var charsCount = CKEDITOR.instances['articletext'].getData().replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, '').replace(/^\s+|\s+$/g, '');
var wordCount = CKEDITOR.instances['articletext'].getData().replace(/[^\w ]/g, "").split(/\s+/);
var max = <?php echo $orderInfo->wordstarget; ?>;
var txtVal = $('#title').val(); //title field value
var descVal = $('#description').val();//description field value
var wordstitle = txtVal.trim().replace(/\s+/gi, ' ').split(' ').length;//words in title
var wordsdesc = txtVal.trim().replace(/\s+/gi, ' ').split(' ').length;//words in description
var text = CKEDITOR.instances['articletext'].getData();
var valueOfText = text + txtVal + descVal;//add all fields text to one
var wordsCountAll = wordCount.length + wordstitle + wordsdesc;//add all fields words to text
xajax_checkKeywords(valueOfText, <?php echo $base_url[3]; ?>, wordsCountAll);
}
所以我需要停止function ck_jq();
一次执行。