0

I am just a beginner with jquery and am trying to call simple request. Here's a jsfiddle:

http://jsfiddle.net/xVrNL/

I am using this code:

HTML:
<button>Click me</button>

and

jQuery:
$("button").click(function() {
    $.ajax({
        url: "http://jsfiddle.net/echo/html/",
        success: function(result) {
            alert("Data: " + result);
        }
    });
});

But it doesn't work. Reading documentation doesn't help me. Can anybody suggest solution?

Thank you very much

........

Jozko Golonka
  • 323
  • 1
  • 2
  • 11
  • 1
    First of all, you have to pick jQuery library from the left sidebar :) – Adaz May 04 '13 at 09:49
  • 1
    Do you see the first select box on the left side? It says *"No-Library (pure JS)"*. You have to change it and select to include jQuery. Please read the documentation (of anything) before you use it: http://doc.jsfiddle.net/. – Felix Kling May 04 '13 at 09:51

3 Answers3

3

These are the reasons for your problem:

  1. You have to refer the jQuery library reference for the jsfiddle
  2. You cant use absolute urls for ajax requests. Please refer the following answer for more information.

$.ajax call working fine in IE8 and Doesn't work in firefox and chrome browsers

Community
  • 1
  • 1
Chamika Sandamal
  • 23,565
  • 5
  • 63
  • 86
1

You need to import latest jQuery library.

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

http://jsfiddle.net/xVrNL/2/ .See this link it is working now

PSR
  • 39,804
  • 41
  • 111
  • 151
0
  1. Set jquery from the left sidebar
  2. remove the domain from "url"

Example jsfiddle.net/xVrNL/3/

(sorry it's not a link but I keep getting a message saying it has to be wrapped with a code even when it was..)

Result: enter image description here

Adaz
  • 1,627
  • 12
  • 14