locked
need to pass json and html... how pass them together.. RRS feed

  • Question

  • User-1312778766 posted

    net.4

    i got a web service that passes json to html from jquery call

    and i need to pass json and some html code as well..

    1)

    for performance reasons - should i unate the 2 calls in to 1 single call..

    2)

    and if so: how may i do that? best practice..

    my json example:

    <?xml version="1.0" encoding="UTF-8"?>
    <string xmlns="http://zimzumim.co.il/">[{"ID":"SE-0546-55-3","H1":"קשיח וחלקלק","H3":null,"LI":null,"isActiv":"True","Price":"269","Tags":"t1 t4 t8 t14 t13 t15","ImgCount":null},{"ID":"SE-0611-25-3","H1":"ה רולס רוייס","H3":null,"LI":null,"isActiv":"True","Price":"699","Tags":"t10 t4 t12 t1 t18","ImgCount":null},{"...........

    my html example:

    <li class="dropdown a-h" data-filter="t1">??? ?????</li><ul><li data-filter="t4">?? ??????????</li><ul><li data-filter="t7">???? ????</li><li data-f

    thanks

    Monday, July 21, 2014 10:30 AM

Answers

  • User-1312778766 posted

    thanks 

    at the end i have added a name value to the same obj as 

    mgebhard has suggest, but i decoded it so i will send a real html markup - its shorter than sanding unicode...

    and i have tested the formating with the link Shawn - MSFT provided.

    so thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 22, 2014 8:37 AM

All replies

  • User475983607 posted

    Can't ya simple add the HTML as a json name value?  Make sure the HTML is encoded though.

    Monday, July 21, 2014 1:14 PM
  • User-1818759697 posted

    Hi,

    You may refer to the following example for sending HTML in JSON:

    Send HTML data in JSON field by prefixing it with "<!DOCTYPE html>" and append "</html>" at the end of the field value, as shown in following example:

    {
      "myhtml_content": "<!DOCTYPE html><html><head><title>Titleofthedocument</title></head><body>Thecontentofthedocument......</body></html>"
    }

    In order to validate if the generated JSON data is valid, you could use JSON Validator/Formmatter.

    Regards

    Tuesday, July 22, 2014 3:45 AM
  • User-1312778766 posted

    thanks 

    at the end i have added a name value to the same obj as 

    mgebhard has suggest, but i decoded it so i will send a real html markup - its shorter than sanding unicode...

    and i have tested the formating with the link Shawn - MSFT provided.

    so thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 22, 2014 8:37 AM