how to use ajax request in jsFiddle

后端 未结 2 1166
Happy的楠姐
Happy的楠姐 2020-12-09 05:19

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;
           


        
相关标签:
2条回答
  • 2020-12-09 05:40

    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);;
        });​ 
    });
    
    0 讨论(0)
  • 2020-12-09 05:41

    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.

    0 讨论(0)
提交回复
热议问题