How do I display a jQuery.get() result in a new browser window?
How can I redirect the result of a jQuery.get command so that it displays in a new browser window (or tab)?
preview: function(pblock, directObject) {
...
jQuery.get(url, params, function(data) {
pblock.innerHTML = ...someFunc.. (data); });
},
execute: function(directObject) {
...
jQuery.get(url, params, function(data) {
openResultDataInNewWindow(data); });
//Utils.openUrlInBrowser(url);
}
What should I put in place of the "openResultDataInNewWindow" function?
preview: function(pblock, directObject) {
...
jQuery.get(url, params, function(data) {
pblock.innerHTML = ...someFunc.. (data); });
},
execute: function(directObject) {
...
jQuery.get(url, params, function(data) {
openResultDataInNewWindow(data); });
//Utils.openUrlInBrowser(url);
}
What should I put in place of the "openResultDataInNewWindow" function?
2
people have this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
-
Inappropriate?Not sure what exactly you need, are you meaning something like:
function openResultDataInNewWindow(data)
{
var msg = "javascript:document.write('${data}')";
var subs = { data: data };
Utils.openUrlInBrowser(CmdUtils.renderTemplate(msg, subs));
} -
Inappropriate?I'm trying to eliminate having to go to a couple websites and manually enter in my information and use the "submit" button. I'm trying to mimic the "submit" on each site by writing an Ubiquity script for each site. One site's form uses a GET and the other one uses a POST. My Ubiquity scripts use jQuery to do the GET and POST.
The websites I'm trying to mimic do two things 1) a search, and 2) submit information to a website. In both instances, the website returns an html document. I'm just confused how to parse or display the resulting document.
I got the scripts to work. At least, my data is submitted to the POST site correctly. I confirmed that it got the information by looking at it later on the site. I just can't display the html page that results from the POST. The search site (using GET) returns html code too. Again, I don't know how to look at it yet.
When I do it normally and use the "submit" button on either site, in both cases, it looks like a new url is generated by the server. At least, the browser *seems to be* redirected to a different url. However, when I do it using jQuery I receive a full html document in response tot he HTTP request. So I'm confused. Again, I don't know how to parse the HTTP response or display it.
The site that I'm trying to search doesn't have an easy to use search url. I can't do a search by encoding the url. When I do it normally, using the search box on the site, the site seems to take the submitted information and generates a search key from it, A sequence of numbers, not the strings I searching for. The browser window is changed to display a url containing the resulting key.
(The answer above opened a new tab and displayed the html code in the url bar.)
execute: function(directObject) {
...
jQuery.get(url, params, function(data) {
// how do I change the browser to display the new data (or url)?
});
} -
Inappropriate?As ShawTim mentioned, I'd go with opening a tab then doing document.write() on it.
I'm not sure how you open an empty tab with ubiquity (only did that with user script for Fire Gestures extension), this site might be helpful to you: https://developer.mozilla.org/En/FUEL
The pseudo-code would look sometihng like
var newtab = Application.activeWindow.addTab();
newtab.document.write(jQueryResponse); -
Inappropriate?There's a thread on google-groups talking about that (opening a tab and adding things to it).
http://groups.google.com/group/ubiqui...
Loading Profile...






