web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Loading image in ajax call in html page added in dynamic crm is not working in chrome

(0) ShareShare
ReportReport
Posted on by

I have a html page where i want to display processing with loading image between ajax call for save and its success. And that page i put in dynamics crm as webresourse.

Problem is that Loading works fine in firefox but not working in chrome.

<script src="ajax.googleapis.com/.../jquery.min.js"></script>
<img src="sm_loading.gif" id="loading" style="display:none" />
<input class="custom-btn" id="btnsave" value="Save" onclick="SaveData();"  type="button">
function SaveData() {
	$('#loading').show();
	var stocktrack = {};
	stocktrack.sm_Description = descval;
	var jsonPO = window.JSON.stringify(stocktrack);
	var oDataUri = serverUrl + "/XRMServices/2011/OrganizationData.svc/sm_stocktrackingSet";
	$.ajax({
		type: "POST",
		contentType: "application/json; charset=utf-8",
		datatype: "json",
		url: oDataUri,
		data: jsonPO,
		async: false,
		beforeSend: function (XMLHttpRequest) {
			XMLHttpRequest.setRequestHeader("Accept", "application/json");
		},
		success: function (data, textStatus, XmlHttpRequest) {
			debugger;
			$('#loading').hide();
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
			alert(textStatus);
		}
	});
}
									


Please suggest if any solution is there.

*This post is locked for comments

I have the same question (0)
  • Alagunellaikumar Profile Picture
    6,212 on at

    Hi Chhaya_Patel,

    This is due to synchronous in your ajax  code, because if it is synchronous then your code process will wait to proceed next step thread will not release until your synchronous request complete. 

    Try asynch:true

    $.ajax({
    		type: "POST",
    		contentType: "application/json; charset=utf-8",
    		datatype: "json",
    		url: oDataUri,
    		data: jsonPO,
    		async: true
    		beforeSend: function (XMLHttpRequest) {
    			XMLHttpRequest.setRequestHeader("Accept", "application/json");
    		},
    		success: function (data, textStatus, XmlHttpRequest) {
    			debugger;
    			$('#loading').hide();
    		},
    		error: function (XMLHttpRequest, textStatus, errorThrown) {
    			alert(textStatus);
    		}
    	});

    If you find answer please mark as yes
  • Community Member Profile Picture
    on at

    If i need async:false for nested ajax call(ajax call in success of other ajax call) then any solution for that?

  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at
  • Community Member Profile Picture
    on at

    Hi Alagunellaikumar , I try this..This will work good when async:true if false then not work only 1 sec loading comes in last and went.

  • Verified answer
    Alagunellaikumar Profile Picture
    6,212 on at

    Hi Chhaya_Patel,

    As I said earlier Javascript runs in the UI thread, so when async: false it will freeze the browser including all animation.  In the above solution image show but will not animate  

    It is a pain in ajax

    If you find answer please mark as yes

  • Verified answer
    Community Member Profile Picture
    on at

    I Got my answer.

    With the use of setTimeout(function(){..our code..},10); I am able to display loading in chrome with async:false.

    Reference Link:

    www.experts-exchange.com/.../jQuery-async-false-with-beforeSend.html

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans