Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Saving to Database via AJAX: The Fallback if JavaScript is Disabled

$
0
0

Dear All

I have created a simple form and have decided to use AJAX to save the data back to an SQL database. I'm curious though, if the user's browser doesn't support JavaScript for whatever reason, is there a best practice approach that means we fall back to submitting the data back to the server via a postback and deal with it that way?

Presumably we don't say if the user's browser can't handle JavaScript at that moment in time that they just can't save back to the database?

$('#btnsubmit').click(function () {
                    var RegistrationChildSurname = $('#fpChildSurname').val();$.ajax({
                        type: 'POST',
                        contentType: "application/json; charset=utf-8",
                        url: 'Default.aspx/Registration_Save',
                        data: "{'RegistrationChildSurname':'" + RegistrationChildSurname + "'}",
                        async: false,
                        success: function(response) {$('#fpChildSurname').val('');
                            alert("Record saved successfully in database");
                        },
                        error: function() {
                            alert("some problem in saving data");
                        }
                    });<asp:TextBox ID="fpChildSurname" runat="server" ClientIDMode="Static" /><input type="button" id="btnsubmit" value="Submit" />

Many thanks

Daniel


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>