locked
Pass IHtmlString back to jQuery post from my page RRS feed

  • Question

  • User-1989019809 posted

    I'm using jquery to post a variable to a page from which I'd like to return some html. I don't know what syntax I'm meant to use to return the html generated.

    Javascript:

    $.post(
        '/ShowOrder',
        { OrderID: eventid }, 
        function (retgrid) {
            $(this).next().html(retgrid);
        });

    ShowOrder.cshtml:

    @{   
        // ... variable processed here
    
        IHtmlString result = grid.GetHtml();
        
        // What do I put here to send result back?
    }

    Monday, June 30, 2014 7:09 PM

Answers

  • User-760709272 posted

    Just write it as output

    @grid.GetHtml()

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 30, 2014 8:28 PM

All replies

  • User-760709272 posted

    Just write it as output

    @grid.GetHtml()

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 30, 2014 8:28 PM
  • User-1989019809 posted

    Just write it as output

    @grid.GetHtml()

    The jQuery is on a different page to ShowOrder.cshtml. I want to show the grid generated in ShowOrder on the original page, so I'm not sure how that will help me.

    Tuesday, July 1, 2014 2:33 AM
  • User-760709272 posted

    I meant if you update the view to include that line outside of any { } block.  You'll need to add whatever code gets the "grid" variable though, you didn't list that.

    Tuesday, July 1, 2014 4:12 AM
  • User-1989019809 posted

    Ahh, I get it.

    I didn't realise that the whole html of page would be returned - i thought you had to specify what you wanted and use a command to get it sent back to the jQuery.

    That makes much more sense now.

    Thanks.

    Tuesday, July 1, 2014 7:24 AM