XicoXperto Posted July 27, 2012 at 10:51 PM Report Share #470708 Posted July 27, 2012 at 10:51 PM Boas noites malta! Alguém sabe se há alguma possibilidade de a função $.post() ou $.ajax() não conseguirem devolver "type : json" ? Isto é, eu tinha umaa função de editar já a funcionar com uma chamada através do $.post() que devolvia objecto json, mas de um dia para o outro deixou de funcionar (não me lembro de alterar nada relativo a ele). Verifiquei que ao tirar o tipo (json) da função $.post() ele devolve a string com os dados formatados em json, mas se puser a função para devolver o objecto json ele dá erro, nem sequer entra no callback e vai directo para o $.post().error(); Já estou a volta disto à umas horas e realmente não consigo perceber o problema. Pergunto-me se poderá ser do browser, algum update que tenha feito... Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 28, 2012 at 12:17 AM Report Share #470742 Posted July 28, 2012 at 12:17 AM podes colocar aqui o JSON ou fornecer um URL para o script que te fornece o JSON ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
XicoXperto Posted July 28, 2012 at 12:52 AM Author Report Share #470748 Posted July 28, 2012 at 12:52 AM (edited) estive a identa-lo para ser mais facil entender { "data": { "personal": [ { "id":"8","name":"combo","bornDate":"2001-03-31","parentType":"4" } ], "contacts": [ { "id":"8","contact":"11234567890","contactType":"1" }, { "id":"9","contact":"21234567890","contactType":"2" }, { "id":"10","contact":"31234567890","contactType":"3"}, {"id":"11","contact":"41234567890","contactType":"1"} ], "documents": [ {"id":"8","document":"11093810ASD","documentType":"1"}, {"id":"9","document":"21093810ASD","documentType":"2"}, {"id":"10","document":"31093810ASD","documentType":"3"}, {"id":"11","document":"41093810ASD","documentType":"4"} ], "jobs": [ {"id":"7","job":"1Empresa XTPO","dateStart":"1998-01-01","dateEnd":"0000-00-00","value":"1123.00","jobType":"1"}, {"id":"8","job":"2Empresa XTPO","dateStart":"1998-01-02","dateEnd":"0000-00-00","value":"2123.00","jobType":"2"}, {"id":"9","job":"3Empresa XTPO","dateStart":"1998-01-03","dateEnd":"0000-00-00","value":"3123.00","jobType":"3"} ], "pensions":null, "comments": [ {"comments":""} ] }, "form":"<div class=\"wrapperPerson\"><div class=\"sideWrapper\" id=\"left\"><div class=\"blueTopOpen\" id=\"personal\"><div class=\"title\"> <p> Dados Pessoais <\/p> <\/div><div class=\"container\"><span class=\"personal\" id=\"person8-personal\"><input id=\"realID\"type=\"hidden\" name=\"person[8][personal][id]\" value=\"0\" \/><input class=\"personName\" id=\"person8-name\" type=\"text\" name=\"person[8][personal][name]\" value=\"Nome\" \/><div class=\"inputTextWithDatePicker\"><input class=\"bornDate\" id=\"person8-bornDate\" type=\"text\" na.../p> <\/div><div class=\"container\"><span class=\"comment\" id=\"person8-comment\"><textarea class=\"comments\" id=\"person8-comments\" name=\"person[8][personal][comments]\" value=\"Observacoes\">Observa\u00e7\u00f5es<\/textarea><\/span><\/div><div class=\"clean\"><\/div><\/div><\/div><input id=\"id\"type=\"hidden\" name=\"person[8][id]\" value=\"8\" \/><input id=\"person8-hiddenContacto\"type=\"hidden\" name=\"person[8][total][contacts]\" value=\"4\" \/><input id=\"person8-hiddenDocumento\"type=\"hidden\" name=\"person[8][total][documents]\" value=\"4\" \/><input id=\"person8-hiddenEmprego\"type=\"hidden\" name=\"person[8][total][jobs]\" value=\"3\" \/><input id=\"person8-hiddenPens\u00e3o\"type=\"hidden\" name=\"person[8][total][pensions]\" value=\"0\" \/><div class=\"divider\"><\/div><span class=\"formSubmitButtons\"><div class=\"buttonWithIconAndText\" id=\"check\" name=\"person8[actions][form]\" type=\"check\" value=\"Adicionar\"><label>Adicionar<\/label><img src=\"images\/style\/inputs\/icons\/check.png\" \/><\/div><div class=\"buttonWithIconAndText\" id=\"reset\" name=\"person8[actions][form]\" type=\"reset\" value=\"Limpar\"><label>Limpar<\/label><img src=\"images\/style\/inputs\/icons\/broom.png\" \/><\/div><div class=\"buttonWithIconAndText\" id=\"cancel\" name=\"person8[actions][form]\" type=\"cancel\" value=\"Cancelar\"><label>Cancelar<\/label><img src=\"images\/style\/inputs\/icons\/cancel.png\" \/><\/div><\/span><div class=\"clean\"><\/div> <\/div>" } 0 este código foi copiado de um alert e é feito através da função json_encode() do php. É normal ter um 0 no final? fiz upload para o servidor, podes ver em : http://ba.dotslashsource.com/ Edited July 28, 2012 at 12:49 AM by XicoXperto Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 28, 2012 at 12:54 AM Report Share #470751 Posted July 28, 2012 at 12:54 AM deves ter reparado na existência de um 0 no final do json que apresentaste, não ??? se isso não resultar, altera todos os \" por ' no html ... já tive problemas por causa disso ... 1 Report IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
XicoXperto Posted July 28, 2012 at 12:56 AM Author Report Share #470753 Posted July 28, 2012 at 12:56 AM pois, eu perguntei acerca disso, ok, vou tentar descobrir porque é que ele acrescenta um 0. como referi usei uma função php que faz transforma o array em json (http://php.net/manual/en/function.json-encode.php) tenho de ver se entendo de onde vem o 0 Obrigado Link to comment Share on other sites More sharing options...
brunoais Posted July 28, 2012 at 08:01 AM Report Share #470774 Posted July 28, 2012 at 08:01 AM Esse 0 vem provavelmente de um echo esquecido aí depois do json_encode... "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%. Link to comment Share on other sites More sharing options...
XicoXperto Posted July 28, 2012 at 08:06 AM Author Report Share #470775 Posted July 28, 2012 at 08:06 AM Já descobri, quando andei a fazer algumas alterações provavelmente apaguei um "break" sem querer no switch e então ele tentava fazer a seguinte instrução, e o 0 vinha daí. Obrigado malta, já andava a dar em maluco! ^^ 👍 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now