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

  • Question

  • User1956385013 posted

    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();
                            type: 'POST',
                            contentType: "application/json; charset=utf-8",
                            url: 'Default.aspx/Registration_Save',
                            data: "{'RegistrationChildSurname':'" + RegistrationChildSurname + "'}",
                            async: false,
                            success: function(response) {
                                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


    Monday, February 17, 2014 7:03 PM


  • User-417640953 posted

    Hi djs25uk,

    Thanks for your post.

    As we all know that browser use the html form to submit the data to server side with the http protocol.

    And the http protocol is stateless and connectionless, it based on the request-response model betwwen client side and server side.

    A client (browser) submits an HTTP request to the server; then the server returns a response to the client.

    The response contains status information about the request and may also contain the requested content.

    Two commonly used methods for a request-response between a client and server  are: GET and  POST.

    • GET - Requests data from a specified resource
    • POST - Submits data to be processed to a specified resource


    As for the Ajax it is asynchronous javaScript and XML. AJAX is not a new programming language, but a new way to use existing standards.

    Ajax is the art of exchanging data with a server, and updating  parts of a web page - without reloading the whole page.

    Ajax based on the javascript and xml, if the browser not supports javascript, it can not submit data to server side using ajax.


    Hope this helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 19, 2014 2:48 AM