Running Tinymce multiple ajax calls issue - ajax

I have been sending multiple ajax calls from a single page and trying to load TinyMCE with each ajax call. But TinyMCE loads only the first time.
The code I have been using after AJAX success:
success: function(html) {
$('#showmail').html(html);
$(".mceSimple").each(function(){
tinymce.execCommand('mceRemoveControl',true,'elm1');
tinyMCE.execCommand("mceAddControl",true, 'elm1');
});
Could someone tell me what I am doing wrong

You need to shut down tinymce correctly before reinitializing an editor with the same id a second time.
To shut down an edtor instance use:
tinymce.execCommand('mceRemoveControl',true,'editor_id');
To reinitialize use
tinymce.execCommand('mceAddControl',true,'editor_id');

Related

In ie11 ajax call -window.location redirect not working, extjs

I am facing an issue with redirecting to another domain, from ajax call success in ie. It shows issue only in ie, in chrome and firebox it works well. I am using extjs for ajax call and in response i want to redirect to another domain based on the success value.
But if i place an javascript alert in the ajax success it works in ie.
If we place the same redirection code outside success of ajax call it works.
Ext.Ajax.request({
url: 'API/LogOut.ashx',
scope: this,
success: function (response) {
var result = response.result.data;
if (result['LogOutUrl'])
{
window.location.assign(result['LogOutUrl']);
I even tried to redirect like this window.location.assign('/tax.aspx'). But even this is not working. Anybody has any clue on that.
I also faced same issue for IE browser, in IE due to security it blocks window redirection like window.open().It results in popup blocker.
Try using delayed task or setTimeout() after your ajax response comes.
Ext.Ajax.request({
url: 'API/LogOut.ashx',
scope: this,
success: function (response) {
var result = response.result.data;
if (result['LogOutUrl'])
{
setTimeout(function(){
window.location.assign(result['LogOutUrl']);
},1000);
...
Post your result here.If possible give some fiddle link.

Symfony2, jQuery Ajax request, web debug toolbar, 500 Internal Server Error

I am developing an application with Symfony2 platform that, at one moment, makes a simple AJAX request on document ready.
jQuery.ajax({
url: 'test.php',
type: 'POST',
data: {
'test': 'test'
},
success: function( response ){
jQuery( 'div#container' ).html( response );
}
});
The problem is that on app_dev.php, where the debug toolbar is loaded, an 500 error is throwed.
More precisely, the AJAX response from the 'test.php' file is received and loaded in the div container, but then, when it tries to load the toolbar, I receive an alert message:
"An error occured while loading the web debug toolbar (500: Internal
Server Error). Do you want to open the profiler?"
If I open profiler, I don't see anything wrong.
If I open the xhr request for the toolbar, a FastCGI 500 error is displayed:
Module FastCgiModule
Notification ExecuteRequestHandler
Handler PHP54_via_FastCGI
Error Code 0x000000ff
If I don't try to make the AJAX request, the toolbar is loaded with no problem.
If I make the request by hand (event on a button) after the toolbar is loaded, again, no problem. If I make the request by hand (event on a button) before the toolbar is loaded the error is throwed.
Notes:
This error occur only on the local machine (with ISS 7.5, PHP 5.4.14). On the production server (IIS server 8.0, same and PHP) the AJAX request is made, and the toolbar is loaded with no problems. I have replaced the php.ini on the local machine with the php.ini from the production server - same problem.
Initialy AJAX request was loading the result of a simple bundle controller method, but then I have tried with a simple PHP file 'test.php', same problem.
I have tried with post and get methods to make the request.
Does anyone have any ideea what goes wrong?
This is not a serious problem since I have multiple options the develop this app, but is bugging me, and I already lost a enough time with this.
PS: if it make any difference, on same machine I have developed an application - no framework - that makes, multiple simultaneos ajax requests.
The following will not fix your error, but provides an alternative way to possibly achieve your need. It seems you want to load asynchronously a part of your website, Symfony2 provides a solution for that: ESI render.
The doc is here: http://symfony.com/doc/current/book/templating.html#asynchronous-content-with-hinclude-js
This method will create an ajax call only then your page will be rendered.

Call ajax when MVC project starts

When I start my MVC application I want to call:
$.ajax({
url: "#Url.Action("CreateInstance", "Home")",
type: "POST"
});
This works! But I want to call it only once. If I switch from page to page this function is still getting called. I only want to call the function if I start the project.
Is this possible?
You probably want to call the code directly in your global.asax . If you aren't outputting any data to the page, why use ajax?

ASP.NET MVC 3 - enabled unobtrusive javascript, ajaxComplete fires once and never again

Before unobtrusive javascript, I handled ajax complete events with the following register:
Sys.Net.WebRequestManager.add_completedRequest(myHandler);
This event handler will fire every time an ajax request is complete. I also have an ajaxComplete event bind in $(document).ready(), to handle ajax calls exclusively through jQuery:
$.ajaxComplete(function (e, xhr, settings) {
myHandler(xhr)
});
Which also works great. But I get a different behavior when I enabled unobstrusive javascript in ASP.NET MVC 3. It fires the first time when the first ajax call is complete, but on subsequent ajax requests, ajaxComplete event never fires again.
Now, I know about that you need to call $.validate.unobtrusive.parse() to rebuild the validation after the elements in the form updated via partial postback. Is there something similar that I need to do to make sure that ajaxComplete can fire again on subsequent requests? I cannot find the documentation on this.
FYI: I have included all the jquery*.js libs to support unobtrusive javascript. I also have the MicrosoftMvc*.js libs included to support legacy code in the project. I was hoping to convert everything over until I ran into this problem.
You need to actually attach ajaxComplete to an element I thought?
$('.info').ajaxComplete(function() {
var info = $(this);
info.html('Success!');
});
You should only need to attach ajaxComplete to an element once in its lifetime.

CakePHP Concurrent AJAX Requests Blocking

I am working with CakePHP on an app which has to run a time-consuming task via a single AJAX call, with secondary periodical AJAX calls checking on the progress of the task.
The Problem
While the time-consuming task (which takes >30 seconds) is running via it's AJAX request to CakePHP, the secondary progress AJAX request seems unable to be "blocking".
To clarify, the secondary progress AJAX request does not return any error, it simply does not return any response until the original time-consuming request finishes.
Once this original AJAX request finishes, the secondary progress AJAX request returns as expected.
It seems that execution of the progress request is being queued until the first AJAX call finishes, as the progress returned is 100%.
What I've Tried
I have tried multiple suggested solutions, including:
Changing the session handler to 'cake' in core.php - no fix
Setting the config security level to 'medium' in core.php - no fix
Disabling user agent checks in core.php - no fix
Testing multiple concurrent AJAX calls to a plain PHP script on the same server - works as expected
Any Ideas?
So it seems as though the issue is caused by CakePHP - has anyone experienced this in their own CakePHP app?
Thanks!
Session handling is set to file in php
from php.ini
[Session]
; Handler used to store/retrieve data.
; http://php.net/session.save-handler
session.save_handler = files
This prevent php from running more than one instance of session per user.
To prevent this run this in your php code:
session_write_close();
Just know session is now closed, so writing to session is no longer an option.
For some clarification, are you using the built-in AJAX helper (on prototype) or some external library like jQuery?
Usually, the javascript library of choice has an {async: true} available to force concurrency. See this example:
$.ajax({
type: 'GET',
url: '/fetch.php',
async: true,
success: function(data, status) {
$('#status').html(status);
}
});
For the built-in CakePHP AJAX helper, this option should do the trick: $options['type']. More info here. Do note that the AJAX helper is deprecated as of version 1.3 and the jsHelper should be able to takeover, see the request() method here for instance (also has an option called async).

Resources