ajax javascript

조회수 60회
읽지 않은 첫 메시지로 건너뛰기

eric cuver

읽지 않음,
2016. 6. 7. 오후 5:40:2816. 6. 7.
받는사람 brython
hi everybody

how I can use the ajax javascript with brython

 var xhttp = new XMLHttpRequest()
 i test window.XMLHttpRequest but doesnt work because the "new"

thank you

Kiko

읽지 않음,
2016. 6. 8. 오전 2:20:4216. 6. 8.
받는사람 bry...@googlegroups.com
The following code should work

from browser import window
from javascript import JSConstructor

xhttp = JSConstructor(window.XMLHttpRequest)()



--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/6cad222b-d4ad-41d1-ae6d-4df550081792%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

eric cuver

읽지 않음,
2016. 6. 8. 오전 3:05:1016. 6. 8.
받는사람 brython
cool it's work i finish today apple/android/window phone application coding entirely Brython !!!!

Kiko

읽지 않음,
2016. 6. 8. 오전 3:15:4616. 6. 8.
받는사람 bry...@googlegroups.com
2016-06-08 9:05 GMT+02:00 eric cuver <amihaco...@gmail.com>:
cool it's work i finish today apple/android/window phone application coding entirely Brython !!!!


Great, if it is possible to have a demo it would be great.
We could add this to the brython gallery or to the 'brython in the wild' wiki (https://github.com/brython-dev/brython/wiki/Brython%20in%20the%20wild).


 

eric cuver

읽지 않음,
2016. 6. 8. 오전 3:28:1816. 6. 8.
받는사람 brython
yes  it is an application I have to put everything online tonight I am sending you the link is an application for a startup

Kiko

읽지 않음,
2016. 6. 8. 오전 3:44:5516. 6. 8.
받는사람 bry...@googlegroups.com
2016-06-08 9:28 GMT+02:00 eric cuver <amihaco...@gmail.com>:
yes  it is an application I have to put everything online tonight I am sending you the link is an application for a startup

Cool, let's see the final result of your hard work!!
 

eric cuver

읽지 않음,
2016. 6. 8. 오전 4:19:1016. 6. 8.
받는사람 brython
on android 4.0

xhttp = JSConstructor(window.XMLHttpRequest)()
it give me this error :
Internal javascript error : TypeError : <TypeError: cannot call method 'apply' of undefined

Kiko

읽지 않음,
2016. 6. 8. 오전 4:24:1216. 6. 8.
받는사람 bry...@googlegroups.com
2016-06-08 10:19 GMT+02:00 eric cuver <amihaco...@gmail.com>:
on android 4.0

xhttp = JSConstructor(window.XMLHttpRequest)()
it give me this error :
Internal javascript error : TypeError : <TypeError: cannot call method 'apply' of undefined

Are you using a WebView?
 

eric cuver

읽지 않음,
2016. 6. 8. 오전 4:39:1016. 6. 8.
받는사람 brython
yes it's webview cordova android 4.1.1 

Kiko

읽지 않음,
2016. 6. 8. 오전 5:07:0016. 6. 8.
받는사람 bry...@googlegroups.com
2016-06-08 10:39 GMT+02:00 eric cuver <amihaco...@gmail.com>:
yes it's webview cordova android 4.1.1 

Uff, I have not idea about that. I don't know if it uses chrome, the android browser, other stuff under the hood.

I tried the following example (http://jsfiddle.net/23u56ct9/) on my android (v4.4.4) with chrome and it doesn't work but it works with FF on the same mobile. But with the mobile I can't debug anything.

I can't dive more now (I'm working).

Did you imported window?

from browser import window
 

eric cuver

읽지 않음,
2016. 6. 8. 오전 5:54:0416. 6. 8.
받는사람 brython
brython 3.2.6 on Netscape 5.0 (linux; u; android 4.1.1; fr-fr; cink peax build / jr003c) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30

yes i made : 
from browser import window




Le mercredi 8 juin 2016 11:07:00 UTC+2, kiko (on pybonacci) a écrit :




yes  

eric cuver

읽지 않음,
2016. 6. 8. 오전 6:18:2816. 6. 8.
받는사람 brython
when I call a script javascript ajax from Brython it works but it's not great I have less control over my ajax calls

Kiko

읽지 않음,
2016. 6. 8. 오전 6:21:0516. 6. 8.
받는사람 bry...@googlegroups.com
2016-06-08 12:18 GMT+02:00 eric cuver <amihaco...@gmail.com>:
when I call a script javascript ajax from Brython it works but it's not great I have less control over my ajax calls

if you use window.XMLHttpRequest you should have similar control as you are using the JS object directly...
 

eric cuver

읽지 않음,
2016. 6. 8. 오전 9:27:4616. 6. 8.
받는사람 brython
look if i code that it work :

function Get (emailval, passwordval) {

var req = new XMLHttpRequest();
 loadingdiv = document.getElementById('loading');
loadingdiv.style.display = "block";
req.open("GET", 'xxxxxxxxxxxx + email + password , false);
req.onreadystatechange = function (aEvt) {
  if (req.readyState == 4) {
     if(req.status == 200)
   document.getElementById("resultat").innerHTML=  req.responseText '),
    


     else
      document.getElementById("resultat").innerHTML="Erreur pendant le chargement de la page",
      alert(req.responseText) 
    

}
else {


}

};
req.send(null);





// body...  
}



brython code

from browser import alert, window
from javascript import JSConstructor

rectangle = JSConstructor(window.Get)
Get(password, email)

but this code doesent work

Pierre Quentel

읽지 않음,
2016. 6. 8. 오전 11:21:2916. 6. 8.
받는사람 brython


Le mercredi 8 juin 2016 12:21:05 UTC+2, kiko (on pybonacci) a écrit :


2016-06-08 12:18 GMT+02:00 eric cuver <amihaco...@gmail.com>:
when I call a script javascript ajax from Brython it works but it's not great I have less control over my ajax calls

if you use window.XMLHttpRequest you should have similar control as you are using the JS object directly...
 

This may be related to issue #373 : for some browsers, XMLHttpRequest is not a function, and in this case
using JSConstructor fails. You should try to use the Brython ajax module instead of window.XMLHttpRequest
 

eric cuver

읽지 않음,
2016. 6. 8. 오후 1:31:3316. 6. 8.
받는사람 brython
dans ce cas il faut que j'installe le server brython pour que l'ajax fonctionne  vue que je suis en local sur l'application ?

eric cuver

읽지 않음,
2016. 6. 8. 오후 2:55:1116. 6. 8.
받는사람 brython
in this case I have to install the server Brython works for the ajax view I am local to the web application?


Le mercredi 8 juin 2016 17:21:29 UTC+2, Pierre Quentel a écrit :

Pierre Quentel

읽지 않음,
2016. 6. 8. 오후 3:44:3916. 6. 8.
받는사람 brython


Le mercredi 8 juin 2016 19:31:33 UTC+2, eric cuver a écrit :
dans ce cas il faut que j'installe le server brython pour que l'ajax fonctionne  vue que je suis en local sur l'application ?
Non, par contre il faut intégrer Brython par <script src="brython_dist.js"> pour améliorer le chargement des modules, dont ajax.

eric cuver

읽지 않음,
2016. 6. 9. 오전 5:57:4216. 6. 9.
받는사람 brython
Il existe une version mimifier de ce brython JS car il gros et lent au chargement

eric cuver

읽지 않음,
2016. 6. 9. 오전 8:32:3816. 6. 9.
받는사람 brython
je pense que je vais plutot utilise JQUERY  avec le POST ET GET
comme ça 
jq = window.jQuery.noConflict(True)
jq= jq("div")
전체답장
작성자에게 답글
전달
새 메시지 0개