Is auto post back in ASP.net and AJAX are the same? - javascript

Is auto post back in ASP.net and AJAX are the same??? I want to send data to server and store that data in XML file without refreshing the page. I dont want to use ajax.. If there is any other way to do this with plain javascript then do let me know... thanks in advance...

Is auto post back in ASP.net and AJAX are the same???
Not from a users perspective. When doing a postback, the user will see his entire page getting refreshed. When using AJAX, the user will not see his page get refreshed
I want to send data to server and store that data in XML file without
refreshing the page. I dont want to use ajax.. If there is any other way
to do this with plain javascript
If you want to interact with the server without refreshing the page, you have to use AJAX.
Note: You may be confusing AJAX with the various AJAX controls / libraries like AjaxControlToolKit etc. If that is the case, then you can definitely use AJAX without using any of the libraries / controls. That is done by using the XMLHTTPRequest and XMLHTTPResponse objects directly via Javascript. However, that in itself is AJAX. Sample code of how to do it can be seen in this page
So, atleast as far as i know, you need to use AJAX to go to the server without appearing to the user that your page has gotten refreshed.

as InSane said PostBack is quite different in AJAX and asp.net. AJAX mostly use Partial postback using XMLHTTPRequest Objects while full page postback sends complete Page's data to server resulting in complete page recycle.
For Your second question.. if you don't want to postback and still want to send some data to server there is only one way to do this by AJAX. AJAX in javascript is quite obscure i'll prefer using some javascript library like JQuery. Here is a link that shows how to call WebMethod on an ASPX page from JQuery.
http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Hope this will help.
Regards.

Related

How can I pass data from one page to another in PHP and Javascript without from?

How can I pass data from one page to another page in PHP using Javascript without from?
In my blog have a post comment with email Id
and this is routing using foreach loop
problem occur when get email id and comment
how can i do this? plz help
you can make use of client side cookie for this. one page you create cookie and on second page read that cookie.
I guess that what you dislike with forms is the page reloading on the client side.
If that is the case then you can use ajax requests (maybe with the help of a framework like jQuery, or pure javascript with the xmlHTTPRequest()).
Alternatively you can use cookies, but it's not what they really are for.
If you don't mind the page reloading, you can also use HTTP GET requests with javascript :
location.assign("http://www.my_site.com/index.php?param1=value1&param2=value2");
You can also store data in Web storage if the data doesn't necessarily need to be processed in PHP.
You will need to have a backup system in cookies though for the older browsers that do not support his.

Angularjs form with and without refresh

I would like to use an Angularjs form directive in the following way: if it's in /home redirect to /search/term and if already in /search process the submit without page refresh just changing the location. I know how to do both, but I don't know how to write a reusable code which works in both examples.
You won't be able to submit form data without a page refresh, unless you submit the data asynchronously via XHR.
It sounds like you are submitting synchronously via HTTP POST or GET at /home, which would result in a page refresh. You will need to write some Angular code to take the values from the form controls and submit it via XHR POST or GET.
It's two quite different approaches so may be difficult to write something reusable.
Essentially one is a plain old HTML methodology whereas the other requires a a bit more sophistication and some Javascript.

Update records without refresh

Apologies if this has been asked before but I'm not sure what to search for exactly so I thought it would be better to explain it.
I am using php to get records from a mysql table and present them. However I have added couple of dropdowns and search boxes to filter out the results and I would like to do it without refreshing the page. Can anyone point me to a tutorial or something like that? I guess I should use jQuery but as I said I don't know what to look for exactly.
Thank you!
You need to use AJAX at client side:
Here are few good examples:
http://www.w3schools.com/php/php_ajax_database.asp
Using Jquery Ajax to retrieve data from Mysql
You can use ajax in jQuery.
Here is a quick look at the ajax API.
And a tutorial guide for ajax:
http://learn.jquery.com/ajax/
And a tutorial for getting started with jquery ajax call
http://www.keyboardninja.eu/webdevelopment/jquery-ajax-call-tutorial
AJAX is a technique for creating fast and dynamic web pages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
The XMLHttpRequest object is part of a technology called Ajax (Asynchronous JavaScript and XML). Using Ajax, data could then be passed between the browser and the server, using the XMLHttpRequest API, without having to reload the web page
You can get AJAX Examples Here

Passing a JSON object to a ASPX page from Javascript

I'm have a page that's rendered in JS that loads some info from the server that the user can edit. The page has a "pop out" option (similar to gmail when you compose an email and can pop it out to another window).
Here's my problem, if the user changes any of the info in the page I don't want that to be lost when the page is popped out. There is far too much information in the page to pass it all in the URL so I was thinking the best way would be to send a JSON object to the ASPX page and have it parse the information into itself.
I've seen this done through Web Services but I was wondering if it would be possible to do it just through an ASPX page. Am I even on the right track or is there a better way to get the data from the JS code into the ASPX page that I'm overlooking?
Thanks!
You could create a PageMethod on the ASPX page, and use that to process the JSON data.
Take a look at this nice article from Encosia.com: http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/
the answer is yes. you can use call page method from client side
here is an example using jQuery to directly call ASP.NET AJAX page methods

Persist javascript changes on the server side

Does any body know how to persist javascript changes on the server side.
For example if I added items to a drop down list client side, how can i persist them in order to read them on the server side.
By the way, Telerik control have this feature.
Your questions doesn't contains any details, so I can only give you a generic answer:
You have to post the new data back to the server, either by using AJAX (I'd suggest using jQuery) or by sumbitting the new data in some field (preferably hidden) with a regular html-form (can be done in JavaScript or by having the user click "submit").
You need to tell the server what the Javascript did using AJAX or a hidden field.

Categories