Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

Javascript to update an MSSQL record without reloading the web page

Hello,

I am looking for a script to update an MSSQL Record when a user clicks a button on a page without reloading the page - is this possible to achieve?

Thanks in advance!
0
Nico2011
Asked:
Nico2011
2 Solutions
 
käµfm³d 👽Commented:
You need to look into AJAX. You'll still need an endpoint on the server that can accept the async request. How you set this up will depend on what framework you are using to build your site.
0
 
Randy PooleCommented:
You would need to use ajax to call a code behind page like asp/php/.net etc
$("#mybutton").click(function() {
    var mydata = $("#mytextfield").val();
    $.ajax({   
       type: 'POST',   
       url: 'update_record.php',   
       data: {mydata:mydata }
    });
  });

Open in new window

In this example you have a button on a form with an ID of mybutton, a text field with an id of mytextfield and a php page with the name of update_record.php which is accepting a form element of mydata.  You would just adjust this accordingly and modify your update_record.php to accept what you need.  Then have that page update your DB.
0
 
Nico2011Author Commented:
Thank you both.  Thanks for the code too Randy - much appreciated!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now