Jquery ve ajax ornek kodlar

Jquery kutuphanesinde kullanılan ajax işlemlerinin gerçekleştirmek için kullanılan methodlar şunlardır.

  • ajax() - Load a remote page using an HTTP request. This is jQuery's low-level AJAX implementation.
  • load() - Load HTML from a remote file and inject it into the DOM.
  • get() - Load a remote page using an HTTP GET request.
  • getJSON() - Load JSON data using an HTTP GET request.
  • getScript() - Loads, and executes, a local JavaScript file using an HTTP GET request.
  • post() - Loads HTML by performing an HTTP post request.
@{
    ViewBag.Title = "Home Page";
}
@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <p>
                @Html.TextBox("textBox1"," deneme", new  { id = "txtStartDate" , size="40"})
                @Html.Label("merhaba", new { id = "lbl" });
                <a href="#" > erkan
                </a>
            </p>
        </div> 
        <div id="toplam"><span id="topla">Saati öğrenmek için tıkla!</span></div> 
     
    </section>
}
@section Scripts {
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.0.js"></script>  
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.js"></script> 
    <script>
        $("#txtStartDate").datepicker();
        $("a").click(function () {
                alert("merhabalar");
        });
        $("#lbl").hover(function () {
            $("a").html("<span>html içeriği değişti.</span>");
        });
        function merhaba() {
            alert("merhaba de fonsiyonu çağrıldı");
        };
    </script>

}
İkinci örnek de Serverdan veri getireceğim.

<script>
        $(document).ready(go);

        function go() {
            $.get("@Url.Action("GetGreeting")",{
                    name: "Kemal"
                }, function (data) {
                    alert(data);
                }
                );
        };
    </script>


        public ActionResult GetGreeting(string name)
        {
            return Content("Hello " + name);
        }

x

x

x

Add comment

The file '/Custom/Widgets/Calendar/widget.cshtml' does not exist.The file '/Custom/Widgets/Category list/widget.cshtml' does not exist.The file '/Custom/Widgets/Tag cloud/widget.cshtml' does not exist.The file '/Custom/Widgets/Page List/widget.cshtml' does not exist.The file '/Custom/Widgets/Month List/widget.cshtml' does not exist.