jquery $.GET parameters passing in the url

this is a general-purpose way to make GET requests with Jquery:

var loadUrl="mypage.php";
$("#get").click(function(){   
    $("#result").html(ajax_load);   
    $.get(   
        loadUrl,   
        {language: "php", version: 5},   
        function(responseText){   
            $("#result").html(responseText);   
        },   
        "html"  
    );   
});  

I was wondering if I could pass parameters (Ex.language and version) directly in the Url(after urlencoding them):

var loadUrl="mypage.php?language=php&version=5";
$("#get").click(function(){   
    $("#result").html(ajax_load);   
    $.get(   
        loadUrl,      
        function(responseText){   
            $("#result").html(responseText);   
        },   
        "html"  
    );   
});  

Is that possible? And anyhow wich is the cleanest solution to make an ajax call if I have all of the parameters I need urlencoded (Ex.rate me)

7
задан Bartzilla 21 March 2011 в 20:31
поделиться