(X)HTML, JavaScript, DHTML, XML, CSS Client scripting tehnologije, Dynamic HTML, Cascading Stylesheets, XML i standardi |
|
Alati teme | Način prikaza |
27. 06. 2007. | #1 |
Milan Cvejic
Wrote a book
|
Post request u drugom prozoru...
Pozdrav,
kako bi moglo da se izvede da automatski napravim post request na neku stranu koristeci samo java script, ali sa tim da se rezultat prikaze u novom prozoru... Tipa da klikom na link event onClick() odradi submit i rezultat prikaze u novom prozoru... Hvala unapred.
__________________
http://weevify.com |
27. 06. 2007. | #2 |
Banned
Knowledge base
Datum učlanjenja: 01.07.2005
Poruke: 1.598
Hvala: 206
140 "Hvala" u 89 poruka
|
<form method="post" action="yourscript" onSubmit="return false;" target="_blank">
this.form.submit(); |
27. 06. 2007. | #3 |
Milan Cvejic
Wrote a book
|
Izgleda da sam lose formulisao pitanje, potrebno je uraditi celu tu pricu bez koriscenja form taga. Znaci samo javascript, i naravno znam da tu trebam da definisem vrednosti koje se postuju... ali to nije problem, problem mi je samo postovanje iz novog prozora...
Hvala.
__________________
http://weevify.com |
27. 06. 2007. | #4 |
VD IT Direktora
Invented the damn thing
Datum učlanjenja: 08.06.2005
Lokacija: Beograd
Poruke: 2.118
Hvala: 503
1.307 "Hvala" u 282 poruka
|
Pa možeš dinamički da generišeš form tag pre nego što ga submituješ.
|
27. 06. 2007. | #5 |
majstor
Wrote a book
|
I meni je to trebalo, tj treba mi idalje. Sa GET rijesis lako tako sto sve parametre potrpas u link, ali ovo je komplikovanije
|
27. 06. 2007. | #6 |
Direktor Kombinata
Invented the damn thing
Datum učlanjenja: 07.06.2005
Poruke: 2.669
Hvala: 44
119 "Hvala" u 64 poruka
|
Nije ništa komplikovano. Evo je funkcija iz activeCollab 1.0 koja na link kači mogućnost submitovanja POST zahteva (to koristim za sve linkove koji vrše neke modifikacije na serveru):
Kôd:
/** * Send post request to specific link * * @param string the_link */ App.postLink = function(the_link) { var form = document.createElement('form'); document.body.appendChild(form); $(form).attr({ 'action' : the_link, 'method' : 'post' }); form.submit(); return false; };
__________________
activeCollab - Project Management and Collaboration Tool iz domaće kuhinje | area51.rs - Blog |
28. 06. 2007. | #7 |
Ivan Dilber
Sir Write-a-Lot
|
moze i ajaxom da se uradi post zahtev koji ce ti vratiti html, i onda samo otvoris novi prozor i upises mu to u innerHTML
__________________
Leadership is the art of getting people to want to do what you know must be done. |
28. 06. 2007. | #8 |
Milan Cvejic
Wrote a book
|
Evo dokle sam dogurao... i sada ova prica radi pod Internet Exploreom i Safarijem, ali ne radi pod firefox-om
Kôd:
str := 'function doSubmit() { document.write("<form name=''submitForm'' action=''http://www.apr.sr.gov.yu/RepsisPublicSite/Search/GeneralEnterpriseSearch.aspx'' method=''post'' target=''_blank''>"); document.write("<input type=hidden name=''ucHeader:rbtnlstChangeCulture'' value=''sr-SP-Cyrl''>"); document.write("<input type=hidden name=''__VIEWSTATE'' value=''dDwtNTYwMzQ1MzM4O3Q8cDxsPEJhc2VQYWdlX1VzZXJTZXNzaW9uSWQ7PjtsPDs+PjtsPGk8MD47aTwxPjs+O2w8dDxwPGw8aW5uZXJodG1sOz47bDzQn9GA0LXRgtGA0LDQs9CwINC/0YDQuNCy0YDQtdC00L3QuNGFINC00YDRg9GI0YLQsNCy0LA7Pj47Oz47dDw7bDxpPDA+O2k8MT47aTwyPjtpPDM+O2k8NT47aTw2PjtpPDc+O2k8OT47PjtsPHQ8O2w8aTwwPjtpPDE+O2k8Mj47aTwzPjtpPDQ+O2k8NT47aTw2Pjs+O2w8dDx0PHA8cDxsPFZpc2libGU7PjtsPG88dD47Pj47PjtwPGw8aTwwPjtpPDE+O2k8Mj47PjtsPHA80KHRgNC/0YHQutC4ICjRm9C40YDQuNC70LjRhtCwKTtzci1TUC1DeXJsPjtwPFNycHNraSAobGF0aW5pY2EpO3NyLVNQLUxhdG4+O3A8RW5nbGlzaDtlbi1VUz47Pj47bDxpPDA+Oz4+Ozs+O3Q8cDxsPFZpc2libGU7PjtsPG88Zj47Pj47Oz47dDxwPGw8VmlzaWJsZTs+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ibVsJlw1bh7s''>"); '. partner maticnaSt isNilOrEmpty ifTrue: [str := str , 'document.write("<input type=hidden name=''ucEnterpriseSearch:SearchGroup'' value=''rbtnFullTitle''>"); document.write("<input type=hidden name=''ucEnterpriseSearch:rbtnSearchType'' value=''Contains''>"); document.write("<input type=hidden name=''ucEnterpriseSearch:txtFullTitle'' value=''' , partner companyName , '''>");'] ifFalse: [str := str , 'document.write("<input type=hidden name=''ucEnterpriseSearch:SearchGroup'' value=''rbtnRegistryCode''>"); document.write("<input type=hidden name=''ucEnterpriseSearch:txtReferenceNumber'' value=''' , partner maticnaSt printString , '''>");']. str := str , 'document.write("<input type=hidden name=''btnFind'' value=''???????''>"); document.write("</form>"); document.submitForm.submit(); };'. self addjavascript: str. ^'<a href="#" onClick="doSubmit()"><b>www.apr.sr.gov.yu</b></a>'
__________________
http://weevify.com Poslednja izmena od LiquidBrain : 28. 06. 2007. u 14:26. |
28. 06. 2007. | #9 |
Душан Бошкић
Qualified
|
Mozda posluzi
Bas me zaintrigirao ovaj zahtev, mislio sam da hoces da napravis post submit totalno bez forme, ali vidim u predhodnom postu, da ih ipak koristis u okviru javascripta, mozda ti ovo posluzi, jutros sam se malo igrao
Kôd:
function Funkcija() { var i, parametar, parametri; var ime = 'getpost'; var method = 'post'; var action = 'PHP.php'; var target = '_blank'; var broj = arguments.length; var forma = document.createElement('form'); forma.setAttribute('id', ime); forma.setAttribute('name', ime); forma.setAttribute('method', method); forma.setAttribute('action', action); forma.setAttribute('target', target); document.body.appendChild(forma); for(i=0; i<broj; i++) { var parametri = arguments[i].split('='); parametar = document.createElement('input'); parametar.setAttribute('type', 'hidden'); parametar.setAttribute('id', parametri[0]); parametar.setAttribute('name', parametri[0]); parametar.setAttribute('value', parametri[1]); document.getElementById(ime).appendChild(parametar); } document.getElementById(ime).submit(); } Kôd:
<a href="#GETPOST" onclick="Funkcija('Test1=Test2','Test3=Test4');">LINK</a> Srecno ...
__________________
In brightest day, in blackest night ... |
28. 06. 2007. | #10 |
Banned
Knowledge base
Datum učlanjenja: 01.07.2005
Poruke: 1.598
Hvala: 206
140 "Hvala" u 89 poruka
|
ti to po onoj narodnoj "sto prosto kad moze komplikovano" ?
Kôd:
function postSubmit(action, postVars) { var form = document.createElement('form'); document.body.appendChild(form); form.action = action; form.method = 'post'; form.target = '_blank'; i=0; hidden = new Array(); for ( keyVar in postVars ) { hidden[i] = document.createElement('input'); hidden[i].type = 'hidden'; hidden[i].name = keyVar; hidden[i].value = postVars[keyVar]; form.appendChild(hidden[i]); } form.submit(); } edit: action ti je url gde hoces da submitujes, a postVars je asocijativni niz kome je kljuc ime varijable koju hoces da submitujes a vrednost... pa vrednost varijable koju submitujes |
|
|
Slične teme | ||||
Tema | Početna poruka teme | Forum | Odgovori | Poslednja poruka |
ne radi mi $smarty.request ? | ivanhoe | PHP | 0 | 20. 02. 2010. 12:39 |
Intervju s nasim drugom boccio | mungos | Linkovi | 0 | 12. 02. 2010. 23:01 |
Imena request variabli | LiquidBrain | PHP | 4 | 16. 09. 2006. 06:53 |
Invalid URI in request | Mr.Paja | Web Hosting, web serveri i operativni sistemi | 0 | 23. 05. 2006. 09:21 |
MySQL Baza na drugom serveru | Petar Marić | SQL baze podataka - Sponzor: Baze-Podataka.net | 6 | 15. 12. 2005. 10:21 |