[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Open file in new window

Posted on 2013-05-21
7
Medium Priority
?
769 Views
Last Modified: 2013-05-21
I have jquery function which calls an action GetReport which returns a pdf file
This is the Action
 return File(renderedBytes, mimeType);

Open in new window


This is the function
function showReport() {
        var clinic = $("#SelectedClinic").val();
        var date = $("#SelectedDate").val();
      var url = "/Reports/GetReport";
         $.get(url, { SelectedClinic: clinic, SelectedDate: date }, function (data) {
             $("#outPut").html(data);
         });
    }

This is the result
result
I would ideally like to open the pdf file in a new window or tab.
I might also like to show the file DIV $("#outPut") but my real question is how to open it in a new window.


By the way this works
@Html.ActionLink("View in new tab","GetReport","Reports", new {SelectedClinic = "Galway"  }, new { target="_blank" })
but i cannot set the SelectedClinic parameter without doing a post.

The SelectedClinic should come from the dropdown.

Thanks
Eamon
0
Comment
Question by:Eamon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 39183982
You will need to open the new window first and have your script run in that.
0
 
LVL 1

Author Comment

by:Eamon
ID: 39183986
$("#outPut").html(data);
in a new window will still not display the report.
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 39184048
But why are you doing it this way

Why not just have

<a href="pathtopdf/file.pdf" _target="blank">Link text</a>

Or

<a href="pathtopdfcontainer.html" _target="blank">Link text</a> and then have the pdf load in this file (or script)?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:Eamon
ID: 39184082
The action GetReport generates the report and returns a file
0
 
LVL 59

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 39184142
Ok I think I understand - you want to open a doc based on the value of the drop down and have it open in a new window?

Can you not do something like the following
function showReport() {
  var clinic = $("#SelectedClinic").val();
  var date = $("#SelectedDate").val();
  var url = "/Reports/GetReport";
  window.open(url + '?SelectedClinic=' + clinic + '&SelectedDate' + date, '_blank');
}

Open in new window

0
 
LVL 1

Author Comment

by:Eamon
ID: 39184190
Thank you
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 39184558
you are welcome - thanks for the points.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question