开发者

Intercepting a form submition into a pop-up window with jquery

I'm using a pop-up window to upload images to imageshack provider using their api.

My goal is, in the main window, to get the returned xml from the form upload inside the pop-up window (in order to get the thumb and image links of the uploaded image) and insert this data into some hidden fields in the main window.

edit My iter is:

  1. The user click a button on my site (example.com)
  2. I open a pop-up with a form inside (example.com/form.html) via window.open
  3. The form's action goes to Imageshack api url
  4. The user upload the image, the form is submitted, imageshack api return some xml.

I need to get that xml in the main window, parse it to get the original image and thumbnail url, then close the pop-up.

This becose i dont like my user to have to copy'n'paste the html from imageshack into a field on my site... its just for convenience.

So, how can I detect when the form gets submitted, and how do I get the returned xml?

p.s: im using imageshack to low tmy servers bandwith and cpu usage for images, so i cant upload the image on my server and then store on imageshack (via serve开发者_Python百科r-side languages)


When you make your ajax request with Jquery, in the callback function is where you should initiate the popup. When the response comes back, store the xml somewhere on the page. Possibly a hidden textarea with an Id.

Once the xml has been stored on the page, you can then access the value with the following line of javascript running inside the popup:

window.opener.document.getElementById('TextBox1').value;


After many try, with all possible tricks&hacks, what i was looking for is not possible, due to browser's security policy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜