views:

37

answers:

1

Hi i'm trying to retrieve and populate a form. The following link with username Testing and password test123 .

The page is returning a correct JSON object (I tested it by putting on screen between paragraph tags) but the populate plugin is not populating. In firebug it show "no such element as" without displaying the element's name. The input field names are exactly the same is in the DB.

any ideas?

A: 

The problem is that your success callback gets passed a string argument, instead of the expected Object/Array, which causes the populate method to treat the whole input as a single unnamed value. This is caused by a typo in the options object passed to your $.ajax() call:

$.ajax({
    // ...
    datatype: 'json'
});

The option names are case sensitive and the correct spelling for the datatype attribute is dataType with a capital tee. By default, if the datatype option is missing/misspelled, jQuery will try to intelligently guess the datatype of the response and return the result as a formatted string (see the jQuery documentation). So just rename the datatype option to dataType and your fields get populated correctly.

Rikki
Thanks a lot. works perfectly now :)
Azriel_