Question

I have to post a data from a page using jquery.load(). I put it on a page with spark viewengine. the post method fire where a button click, will execute a js function.

<script type="text/javascript">
    function displayCheckedOrders() {        
        var $checkedRecords = $(':checked');

        if ($checkedRecords.length < 1) {
            alert('Check a few grid rows first.');
            return;
        }
        var url = '${Url.Action("myaction","Account")}';
        var temp = $('#xresult').load(url, $checkedRecords);
    }
</script>

but, it didn't parse a correct url,

enter image description here

any solution for my problem ?

Was it helpful?

Solution

Yes - view engine will process the view file to create your url - if you put it in external js then url will be taken as is. A simple solution is to move the relevant js function to the view file. Yet another alternative is to parameterize your external js function to accept the url (as parameter) and construct actual value in the view file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top