I'm trying to create my first fiddle. So here's what I want to do with jquery
$('.list').live('click', function(){
var dataPass = 'uid='+ uid;
$.ajax({
type: "POST",
url: "test.php",
data: dataPass,
cache: false,
success: function(html){
//Do something
}
});
});
So how/where do I write the codes for test.php
file? It's going to return some html markup.
Entering and running code JSFiddle has the notion of panels (or tabs if you switch into the tabbed layout), there are 4 panels, 3 where you can enter code, and 1 to see the result. Once you enter code, just hit Run in the top actions bar, and the fourth panel with results will appear.
You can select jQuery, and other extensions and frameworks, from the Frameworks & Extensions drop down. Also, depending on the library selected there are also some other extensions to that library. An example below of jQuery 1.7. 2, you can also include jQuery UI, jQuery Mobile etc.
You can write your functions in VS Code and then copy & paste into the JavaScript console. Or you can try out JSFiddle, a useful tool for experimenting with JavaScript. With JSFiddle, you can write code in the JavaScript box and then execute it by clicking the Run button on the menu bar at the top of the JSFiddle page.
JSFiddle is an online IDE service and online community for testing and showcasing user-created and collaborational HTML, CSS and JavaScript code snippets, known as 'fiddles'. It allows for simulated AJAX calls.
It's not possible to make an AJAX request to a domain other than the current one, as it's a pretty basic security risk.
jsFiddle have an API for testing AJAX requests which you should use instead.
Here's a working fiddle of what you are probably looking for.
I used http://echo.jsontest.com but you can substitute for your valid URL.
var echo = function(dataPass) {
$.ajax({
type: "POST",
url: "/echo/json/",
data: dataPass,
cache: false,
success: function(json){
alert("UID=" + json.uid + "\nName=" + json.value);
}
});
};
$('.list').live('click', function(){
$.get("http://echo.jsontest.com/uid/12345/value/nuno_bettencourt", function(data) {
var json = {
json: JSON.stringify(data),
delay: 1
};
echo(json);;
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With