views:

43

answers:

1

Hi,

i'm writing this jquery script to send data to a php file via ajax it works but am getting this error can any body tell for I can solve this the code is posted bellow so is the error

here is the error which I get after the data is sent.

Item is undefined:   if (item.guid != null) 

here is the code:

// Data 
    dataObj = { correctAnswers: correctAnswers,                
               startTime:startTime,
               startDate:startDate 
               };

    //Post Data To contorler 
    $.ajax({
        type: "POST",
        url: "save",            
        data: dataObj,
        success: function(data) {
            //Need to return the file contents somehow!
            alert("Data sucessfully Sent\n");
        }
    });
A: 

You need to specify that you are sending json to the server. You need to add the following option to your $.ajax

contentType: "application/json; charset=utf-8"

otherwise the function is expecting standard form post by default.

Michal
even with is line include still getting the same error
Oudin
Which script is throwing this error. Your javascript or jquery? And do you get data to your PHP controller successfully ?
Michal