locked
Jquery and Ajax RRS feed

  • Question

  • User-305496339 posted

    I want to run this code when my asp.net page loads. Do I just enclose it inside $(document).ready? Also should all of my script functions be enclosed inside $(document).ready?

    $.ajax({
    type: "POST",
    url: "Customers.aspx/GetCustomers",
    data: '{}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: OnSuccess
    });

    Friday, January 5, 2018 10:09 PM

Answers

  • User475983607 posted

    I want to run this code when my asp.net page loads. Do I just enclose it inside $(document).ready?

    Yes, or at the end of the HTML.

    Also should all of my script functions be enclosed inside $(document).ready?

    Sure, but it is common to see scripts at the end of a and HTML doc.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 5, 2018 10:19 PM