Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi everyone,
I want to make an ajax call to update data on Sys.WebForms.PageRequestManager.getInstance().beginRequest event to update data on server.I want to do this so that there may be no need to set a hiddenfield on each psotback causing button`s client click event.

Iam using old way of XHR Req

C#
var xhr = false;
if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); }
else { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
xhr.onreadystatechange = function () {
    if (xhr.readyState == 4 && xhr.status == 200) {

xhr.open("GET", _pageName, false);
}

so i want to know that if setting last parameter in xhr.open as false will work synchronously,i.e. ajax request will be completed first and then postback event will fire.
If Not,Please suggest me way to achieve it
Posted
Updated 22-Feb-18 1:59am

1 solution

Using ActiveXObject is not just the "old way". This is absolutely unacceptable way, especially in your case, proprietary to Microsoft and extremely unsafe. Actually, for the safety-savvy users, seeing such construct in your JavaScript would be a good reason to put your site in a black list and never visit it again.

Let me ask you, why would you tag your post with jQuery if you don't use jQuery at all? The documentation on jQeury Ajax is quite clear, please use it: http://api.jquery.com/jquery.ajax[^].

—SA
 
Share this answer
 
Comments
Member 10582972 12-Feb-15 13:23pm    
hi,thanks i will use json call using ajax,but please tell me can i make a synchronous call on Sys.WebForms.PageRequestManager.getInstance().beginRequest so that i can update data before any postback ??
Sergey Alexandrovich Kryukov 12-Feb-15 14:36pm    
It sounds as an unrelated issue to me, a separate question. You can use this short manual: https://msdn.microsoft.com/en-us/library/bb398976%28v=vs.140%29.aspx. If something doesn't work for you, please show what have you tried so far.
—СА

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900