tags:

views:

50

answers:

2

Hello,

just a quick question :

 var h = $('#hebergeurJQUERY').val();
 var t = $('#typeJQUERY').val();

function requestData() {
     $.ajax({
     type: "GET",
     url: '12months/months.php',
     data : "hosting="+h+"&type="+t+"",
......

doesnt work while

data : "hosting=Something&type=Something",

Works.

Any idea to something stupid i did (again ?) ;)

Thanks

+2  A: 

I'd change the data key assignment to:

data: {
    hosting: h,
    type: t
}

Doing so will cause jQuery to generate the URL-encoded string that I think you were trying to generate here.

awgy
+2  A: 

If you pass an object to the data parameter, then jQuery handles all the escaping for you which may be a cause of the problem. You might also have hit problems because of the actual timing of the execution of the code. Put the definition into the function itself:

function requestData() {
    $.ajax({
        type : 'GET',
        url : 'months.php',
        data : {
            hosting : $('#hebergeurJQUERY').val(),
            type : $('#typeJQUERY').val()
        }
        ...
    });
}
nickf