Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread DJANGO DEVELOPER
https://meet.google.com/pns-vbmz-sys

On Wed, Nov 24, 2021 at 12:08 AM DJANGO DEVELOPER 
wrote:

> okay
>
>
> On Wed, Nov 24, 2021 at 12:04 AM Duncan Santiago <
> duncansantiag...@gmail.com> wrote:
>
>> let's try google meet.
>>
>> On Tue, 23 Nov 2021 at 11:39, DJANGO DEVELOPER 
>> wrote:
>>
>>> can I have you on anydesk or any meeting tool?
>>>
>>> On Tue, Nov 23, 2021 at 11:31 PM Duncan Santiago <
>>> duncansantiag...@gmail.com> wrote:
>>>
 send me your code then,
 or GitHub repo handle.

 On Tue, 23 Nov 2021 at 11:27, DJANGO DEVELOPER 
 wrote:

> sorry if you get offended because I need a solution. a working
> solution. I am not familiar with javascript. so getting a lot of issues
>
> On Tue, Nov 23, 2021 at 10:38 PM Duncan Santiago <
> duncansantiag...@gmail.com> wrote:
>
>> your page also reloads and results may not be displayed on your
>> frontend, just add this lines on your onclick listerner
>>
>> function(e){ //notice the e parameter, it is the event parameter.
>> e.preventDefault()
>>  your code here.
>>
>> }
>>
>> or you can just paste this on your script section
>>
>>
>> (function () {
>> var output = document.getElementById('output');
>> document.getElementById('post').onclick = function (e) {
>> e.preventDefault()
>>   var data = document.getElementById('data').value;
>>
>>   axios.post('http://127.0.0.1:8000/predict/',
>> JSON.parse(data))
>> .then(function (res) {
>>   output.className = 'container';
>>   output.innerHTML = res.data;
>> })
>> .catch(function (err) {
>>   output.className = 'container text-danger';
>>   output.innerHTML = err.message;
>> });
>> };
>>   })();
>>
>> On Tue, 23 Nov 2021 at 10:34, Duncan Santiago <
>> duncansantiag...@gmail.com> wrote:
>>
>>> do a demo, enter the URL on the text area and click on the post
>>> button.
>>> Then send me the logs on the terminal running Django and also open
>>> the console and send the output,
>>>
>>> On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 okay let me explain.
 I have trained models which tells us that which website is
 legitimate or which website is not legitimate. I have integrated that 
 model
 with my django web app using rest api.
 I tested the API on postman and working.
 now I want to get the result on front end using HTML CSS and
 javascript. so how can I achieve it?

 On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
 duncansantiag...@gmail.com> wrote:

> hello, am not sure what the question is. Kindly elaborate.
>
> On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> I am working on a django based project in which I have integrated
>> ML trained models to check if a https url is legitimate or not. for 
>> this I
>> need javascript or ajax to call a rest api for my form in which I 
>> want to
>> send a post request so that I can check if a https url is legitimate 
>> or not.
>> *NOTE: My code is running successfully and giving correct answers
>> on postman.* so just want to integrate it with my HTML form.
>> *My work:*
>> *form.html:*
>> 
>> 
>>   
>> 
>> 
>> 
>>
>> 
>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
>> rel="stylesheet"
>> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
>> crossorigin="anonymous">
>>
>> SITE URL Form
>>   
>>   
>>   
>>   
>> SITE URL
>> > rows="5">
>>   
>>   POST
>> 
>>
>> 
>>
>> 
>> 
>>   (function () {
>> var output = document.getElementById('output');
>> document.getElementById('post').onclick = function () {
>>   var data = document.getElementById('data').value;
>>
>>   axios.post('http://127.0.0.1:8000/predict/',
>> JSON.parse(data))
>> .then(function (res) {
>>   output.className = 'container';
>>   output.innerHTML = res.data;
>> })
>> .catch(function (err) {
>>   output.className = 

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread DJANGO DEVELOPER
okay


On Wed, Nov 24, 2021 at 12:04 AM Duncan Santiago 
wrote:

> let's try google meet.
>
> On Tue, 23 Nov 2021 at 11:39, DJANGO DEVELOPER 
> wrote:
>
>> can I have you on anydesk or any meeting tool?
>>
>> On Tue, Nov 23, 2021 at 11:31 PM Duncan Santiago <
>> duncansantiag...@gmail.com> wrote:
>>
>>> send me your code then,
>>> or GitHub repo handle.
>>>
>>> On Tue, 23 Nov 2021 at 11:27, DJANGO DEVELOPER 
>>> wrote:
>>>
 sorry if you get offended because I need a solution. a working
 solution. I am not familiar with javascript. so getting a lot of issues

 On Tue, Nov 23, 2021 at 10:38 PM Duncan Santiago <
 duncansantiag...@gmail.com> wrote:

> your page also reloads and results may not be displayed on your
> frontend, just add this lines on your onclick listerner
>
> function(e){ //notice the e parameter, it is the event parameter.
> e.preventDefault()
>  your code here.
>
> }
>
> or you can just paste this on your script section
>
>
> (function () {
> var output = document.getElementById('output');
> document.getElementById('post').onclick = function (e) {
> e.preventDefault()
>   var data = document.getElementById('data').value;
>
>   axios.post('http://127.0.0.1:8000/predict/',
> JSON.parse(data))
> .then(function (res) {
>   output.className = 'container';
>   output.innerHTML = res.data;
> })
> .catch(function (err) {
>   output.className = 'container text-danger';
>   output.innerHTML = err.message;
> });
> };
>   })();
>
> On Tue, 23 Nov 2021 at 10:34, Duncan Santiago <
> duncansantiag...@gmail.com> wrote:
>
>> do a demo, enter the URL on the text area and click on the post
>> button.
>> Then send me the logs on the terminal running Django and also open
>> the console and send the output,
>>
>> On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER <
>> abubakarbr...@gmail.com> wrote:
>>
>>> okay let me explain.
>>> I have trained models which tells us that which website is
>>> legitimate or which website is not legitimate. I have integrated that 
>>> model
>>> with my django web app using rest api.
>>> I tested the API on postman and working.
>>> now I want to get the result on front end using HTML CSS and
>>> javascript. so how can I achieve it?
>>>
>>> On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
>>> duncansantiag...@gmail.com> wrote:
>>>
 hello, am not sure what the question is. Kindly elaborate.

 On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> I am working on a django based project in which I have integrated
> ML trained models to check if a https url is legitimate or not. for 
> this I
> need javascript or ajax to call a rest api for my form in which I 
> want to
> send a post request so that I can check if a https url is legitimate 
> or not.
> *NOTE: My code is running successfully and giving correct answers
> on postman.* so just want to integrate it with my HTML form.
> *My work:*
> *form.html:*
> 
> 
>   
> 
> 
> 
>
> 
> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
> rel="stylesheet"
> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
> crossorigin="anonymous">
>
> SITE URL Form
>   
>   
>   
>   
> SITE URL
>  rows="5">
>   
>   POST
> 
>
> 
>
> 
> 
>   (function () {
> var output = document.getElementById('output');
> document.getElementById('post').onclick = function () {
>   var data = document.getElementById('data').value;
>
>   axios.post('http://127.0.0.1:8000/predict/',
> JSON.parse(data))
> .then(function (res) {
>   output.className = 'container';
>   output.innerHTML = res.data;
> })
> .catch(function (err) {
>   output.className = 'container text-danger';
>   output.innerHTML = err.message;
> });
> };
>   })();
> 
>
> 
>
> 
> https://cdn.jsdelivr.net/npm/bootstrap@5

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread Duncan Santiago
let's try google meet.

On Tue, 23 Nov 2021 at 11:39, DJANGO DEVELOPER 
wrote:

> can I have you on anydesk or any meeting tool?
>
> On Tue, Nov 23, 2021 at 11:31 PM Duncan Santiago <
> duncansantiag...@gmail.com> wrote:
>
>> send me your code then,
>> or GitHub repo handle.
>>
>> On Tue, 23 Nov 2021 at 11:27, DJANGO DEVELOPER 
>> wrote:
>>
>>> sorry if you get offended because I need a solution. a working solution.
>>> I am not familiar with javascript. so getting a lot of issues
>>>
>>> On Tue, Nov 23, 2021 at 10:38 PM Duncan Santiago <
>>> duncansantiag...@gmail.com> wrote:
>>>
 your page also reloads and results may not be displayed on your
 frontend, just add this lines on your onclick listerner

 function(e){ //notice the e parameter, it is the event parameter.
 e.preventDefault()
  your code here.

 }

 or you can just paste this on your script section


 (function () {
 var output = document.getElementById('output');
 document.getElementById('post').onclick = function (e) {
 e.preventDefault()
   var data = document.getElementById('data').value;

   axios.post('http://127.0.0.1:8000/predict/',
 JSON.parse(data))
 .then(function (res) {
   output.className = 'container';
   output.innerHTML = res.data;
 })
 .catch(function (err) {
   output.className = 'container text-danger';
   output.innerHTML = err.message;
 });
 };
   })();

 On Tue, 23 Nov 2021 at 10:34, Duncan Santiago <
 duncansantiag...@gmail.com> wrote:

> do a demo, enter the URL on the text area and click on the post button.
> Then send me the logs on the terminal running Django and also open the
> console and send the output,
>
> On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> okay let me explain.
>> I have trained models which tells us that which website is legitimate
>> or which website is not legitimate. I have integrated that model with my
>> django web app using rest api.
>> I tested the API on postman and working.
>> now I want to get the result on front end using HTML CSS and
>> javascript. so how can I achieve it?
>>
>> On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
>> duncansantiag...@gmail.com> wrote:
>>
>>> hello, am not sure what the question is. Kindly elaborate.
>>>
>>> On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 I am working on a django based project in which I have integrated
 ML trained models to check if a https url is legitimate or not. for 
 this I
 need javascript or ajax to call a rest api for my form in which I want 
 to
 send a post request so that I can check if a https url is legitimate 
 or not.
 *NOTE: My code is running successfully and giving correct answers
 on postman.* so just want to integrate it with my HTML form.
 *My work:*
 *form.html:*
 
 
   
 
 
 

 
 https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
 rel="stylesheet"
 integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
 crossorigin="anonymous">

 SITE URL Form
   
   
   
   
 SITE URL
 >>> rows="5">
   
   POST
 

 

 
 
   (function () {
 var output = document.getElementById('output');
 document.getElementById('post').onclick = function () {
   var data = document.getElementById('data').value;

   axios.post('http://127.0.0.1:8000/predict/',
 JSON.parse(data))
 .then(function (res) {
   output.className = 'container';
   output.innerHTML = res.data;
 })
 .catch(function (err) {
   output.className = 'container text-danger';
   output.innerHTML = err.message;
 });
 };
   })();
 

 

 
 https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
 integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
 crossorigin="anonymous">

 
 
   
>>>

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread DJANGO DEVELOPER
can I have you on anydesk or any meeting tool?

On Tue, Nov 23, 2021 at 11:31 PM Duncan Santiago 
wrote:

> send me your code then,
> or GitHub repo handle.
>
> On Tue, 23 Nov 2021 at 11:27, DJANGO DEVELOPER 
> wrote:
>
>> sorry if you get offended because I need a solution. a working solution.
>> I am not familiar with javascript. so getting a lot of issues
>>
>> On Tue, Nov 23, 2021 at 10:38 PM Duncan Santiago <
>> duncansantiag...@gmail.com> wrote:
>>
>>> your page also reloads and results may not be displayed on your
>>> frontend, just add this lines on your onclick listerner
>>>
>>> function(e){ //notice the e parameter, it is the event parameter.
>>> e.preventDefault()
>>>  your code here.
>>>
>>> }
>>>
>>> or you can just paste this on your script section
>>>
>>>
>>> (function () {
>>> var output = document.getElementById('output');
>>> document.getElementById('post').onclick = function (e) {
>>> e.preventDefault()
>>>   var data = document.getElementById('data').value;
>>>
>>>   axios.post('http://127.0.0.1:8000/predict/', JSON.parse(data))
>>> .then(function (res) {
>>>   output.className = 'container';
>>>   output.innerHTML = res.data;
>>> })
>>> .catch(function (err) {
>>>   output.className = 'container text-danger';
>>>   output.innerHTML = err.message;
>>> });
>>> };
>>>   })();
>>>
>>> On Tue, 23 Nov 2021 at 10:34, Duncan Santiago <
>>> duncansantiag...@gmail.com> wrote:
>>>
 do a demo, enter the URL on the text area and click on the post button.
 Then send me the logs on the terminal running Django and also open the
 console and send the output,

 On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER 
 wrote:

> okay let me explain.
> I have trained models which tells us that which website is legitimate
> or which website is not legitimate. I have integrated that model with my
> django web app using rest api.
> I tested the API on postman and working.
> now I want to get the result on front end using HTML CSS and
> javascript. so how can I achieve it?
>
> On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
> duncansantiag...@gmail.com> wrote:
>
>> hello, am not sure what the question is. Kindly elaborate.
>>
>> On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER <
>> abubakarbr...@gmail.com> wrote:
>>
>>> I am working on a django based project in which I have integrated ML
>>> trained models to check if a https url is legitimate or not. for this I
>>> need javascript or ajax to call a rest api for my form in which I want 
>>> to
>>> send a post request so that I can check if a https url is legitimate or 
>>> not.
>>> *NOTE: My code is running successfully and giving correct answers on
>>> postman.* so just want to integrate it with my HTML form.
>>> *My work:*
>>> *form.html:*
>>> 
>>> 
>>>   
>>> 
>>> 
>>> 
>>>
>>> 
>>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
>>> rel="stylesheet"
>>> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
>>> crossorigin="anonymous">
>>>
>>> SITE URL Form
>>>   
>>>   
>>>   
>>>   
>>> SITE URL
>>> 
>>>   
>>>   POST
>>> 
>>>
>>> 
>>>
>>> 
>>> 
>>>   (function () {
>>> var output = document.getElementById('output');
>>> document.getElementById('post').onclick = function () {
>>>   var data = document.getElementById('data').value;
>>>
>>>   axios.post('http://127.0.0.1:8000/predict/',
>>> JSON.parse(data))
>>> .then(function (res) {
>>>   output.className = 'container';
>>>   output.innerHTML = res.data;
>>> })
>>> .catch(function (err) {
>>>   output.className = 'container text-danger';
>>>   output.innerHTML = err.message;
>>> });
>>> };
>>>   })();
>>> 
>>>
>>> 
>>>
>>> 
>>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
>>> integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
>>> crossorigin="anonymous">
>>>
>>> 
>>> 
>>>   
>>> 
>>>
>>> *myapp/urls.py:*
>>> path('form/', form, name="form"),
>>> path('predict/', predict, name='predict')
>>> *this is the response I am returning:*
>>> if list(model.predict([test]))[0] == 1:
>>> return JsonResponse({"Response":"Legitimate"})
>>> else:
>>>

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread Duncan Santiago
send me your code then,
or GitHub repo handle.

On Tue, 23 Nov 2021 at 11:27, DJANGO DEVELOPER 
wrote:

> sorry if you get offended because I need a solution. a working solution. I
> am not familiar with javascript. so getting a lot of issues
>
> On Tue, Nov 23, 2021 at 10:38 PM Duncan Santiago <
> duncansantiag...@gmail.com> wrote:
>
>> your page also reloads and results may not be displayed on your frontend,
>> just add this lines on your onclick listerner
>>
>> function(e){ //notice the e parameter, it is the event parameter.
>> e.preventDefault()
>>  your code here.
>>
>> }
>>
>> or you can just paste this on your script section
>>
>>
>> (function () {
>> var output = document.getElementById('output');
>> document.getElementById('post').onclick = function (e) {
>> e.preventDefault()
>>   var data = document.getElementById('data').value;
>>
>>   axios.post('http://127.0.0.1:8000/predict/', JSON.parse(data))
>> .then(function (res) {
>>   output.className = 'container';
>>   output.innerHTML = res.data;
>> })
>> .catch(function (err) {
>>   output.className = 'container text-danger';
>>   output.innerHTML = err.message;
>> });
>> };
>>   })();
>>
>> On Tue, 23 Nov 2021 at 10:34, Duncan Santiago 
>> wrote:
>>
>>> do a demo, enter the URL on the text area and click on the post button.
>>> Then send me the logs on the terminal running Django and also open the
>>> console and send the output,
>>>
>>> On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER 
>>> wrote:
>>>
 okay let me explain.
 I have trained models which tells us that which website is legitimate
 or which website is not legitimate. I have integrated that model with my
 django web app using rest api.
 I tested the API on postman and working.
 now I want to get the result on front end using HTML CSS and
 javascript. so how can I achieve it?

 On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
 duncansantiag...@gmail.com> wrote:

> hello, am not sure what the question is. Kindly elaborate.
>
> On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> I am working on a django based project in which I have integrated ML
>> trained models to check if a https url is legitimate or not. for this I
>> need javascript or ajax to call a rest api for my form in which I want to
>> send a post request so that I can check if a https url is legitimate or 
>> not.
>> *NOTE: My code is running successfully and giving correct answers on
>> postman.* so just want to integrate it with my HTML form.
>> *My work:*
>> *form.html:*
>> 
>> 
>>   
>> 
>> 
>> 
>>
>> 
>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
>> rel="stylesheet"
>> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
>> crossorigin="anonymous">
>>
>> SITE URL Form
>>   
>>   
>>   
>>   
>> SITE URL
>> 
>>   
>>   POST
>> 
>>
>> 
>>
>> 
>> 
>>   (function () {
>> var output = document.getElementById('output');
>> document.getElementById('post').onclick = function () {
>>   var data = document.getElementById('data').value;
>>
>>   axios.post('http://127.0.0.1:8000/predict/',
>> JSON.parse(data))
>> .then(function (res) {
>>   output.className = 'container';
>>   output.innerHTML = res.data;
>> })
>> .catch(function (err) {
>>   output.className = 'container text-danger';
>>   output.innerHTML = err.message;
>> });
>> };
>>   })();
>> 
>>
>> 
>>
>> 
>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
>> integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
>> crossorigin="anonymous">
>>
>> 
>> 
>>   
>> 
>>
>> *myapp/urls.py:*
>> path('form/', form, name="form"),
>> path('predict/', predict, name='predict')
>> *this is the response I am returning:*
>> if list(model.predict([test]))[0] == 1:
>> return JsonResponse({"Response":"Legitimate"})
>> else:
>> return JsonResponse({"Response":"Phishing or fake"})
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to dj

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread DJANGO DEVELOPER
sorry if you get offended because I need a solution. a working solution. I
am not familiar with javascript. so getting a lot of issues

On Tue, Nov 23, 2021 at 10:38 PM Duncan Santiago 
wrote:

> your page also reloads and results may not be displayed on your frontend,
> just add this lines on your onclick listerner
>
> function(e){ //notice the e parameter, it is the event parameter.
> e.preventDefault()
>  your code here.
>
> }
>
> or you can just paste this on your script section
>
>
> (function () {
> var output = document.getElementById('output');
> document.getElementById('post').onclick = function (e) {
> e.preventDefault()
>   var data = document.getElementById('data').value;
>
>   axios.post('http://127.0.0.1:8000/predict/', JSON.parse(data))
> .then(function (res) {
>   output.className = 'container';
>   output.innerHTML = res.data;
> })
> .catch(function (err) {
>   output.className = 'container text-danger';
>   output.innerHTML = err.message;
> });
> };
>   })();
>
> On Tue, 23 Nov 2021 at 10:34, Duncan Santiago 
> wrote:
>
>> do a demo, enter the URL on the text area and click on the post button.
>> Then send me the logs on the terminal running Django and also open the
>> console and send the output,
>>
>> On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER 
>> wrote:
>>
>>> okay let me explain.
>>> I have trained models which tells us that which website is legitimate or
>>> which website is not legitimate. I have integrated that model with my
>>> django web app using rest api.
>>> I tested the API on postman and working.
>>> now I want to get the result on front end using HTML CSS and javascript.
>>> so how can I achieve it?
>>>
>>> On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
>>> duncansantiag...@gmail.com> wrote:
>>>
 hello, am not sure what the question is. Kindly elaborate.

 On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER 
 wrote:

> I am working on a django based project in which I have integrated ML
> trained models to check if a https url is legitimate or not. for this I
> need javascript or ajax to call a rest api for my form in which I want to
> send a post request so that I can check if a https url is legitimate or 
> not.
> *NOTE: My code is running successfully and giving correct answers on
> postman.* so just want to integrate it with my HTML form.
> *My work:*
> *form.html:*
> 
> 
>   
> 
> 
> 
>
> 
> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
> rel="stylesheet"
> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
> crossorigin="anonymous">
>
> SITE URL Form
>   
>   
>   
>   
> SITE URL
> 
>   
>   POST
> 
>
> 
>
> 
> 
>   (function () {
> var output = document.getElementById('output');
> document.getElementById('post').onclick = function () {
>   var data = document.getElementById('data').value;
>
>   axios.post('http://127.0.0.1:8000/predict/',
> JSON.parse(data))
> .then(function (res) {
>   output.className = 'container';
>   output.innerHTML = res.data;
> })
> .catch(function (err) {
>   output.className = 'container text-danger';
>   output.innerHTML = err.message;
> });
> };
>   })();
> 
>
> 
>
> 
> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
> integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
> crossorigin="anonymous">
>
> 
> 
>   
> 
>
> *myapp/urls.py:*
> path('form/', form, name="form"),
> path('predict/', predict, name='predict')
> *this is the response I am returning:*
> if list(model.predict([test]))[0] == 1:
> return JsonResponse({"Response":"Legitimate"})
> else:
> return JsonResponse({"Response":"Phishing or fake"})
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e81cf4f0-1208-4623-97f9-4b88f01d67b3n%40googlegroups.com
> 

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread Duncan Santiago
your page also reloads and results may not be displayed on your frontend,
just add this lines on your onclick listerner

function(e){ //notice the e parameter, it is the event parameter.
e.preventDefault()
 your code here.

}

or you can just paste this on your script section


(function () {
var output = document.getElementById('output');
document.getElementById('post').onclick = function (e) {
e.preventDefault()
  var data = document.getElementById('data').value;

  axios.post('http://127.0.0.1:8000/predict/', JSON.parse(data))
.then(function (res) {
  output.className = 'container';
  output.innerHTML = res.data;
})
.catch(function (err) {
  output.className = 'container text-danger';
  output.innerHTML = err.message;
});
};
  })();

On Tue, 23 Nov 2021 at 10:34, Duncan Santiago 
wrote:

> do a demo, enter the URL on the text area and click on the post button.
> Then send me the logs on the terminal running Django and also open the
> console and send the output,
>
> On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER 
> wrote:
>
>> okay let me explain.
>> I have trained models which tells us that which website is legitimate or
>> which website is not legitimate. I have integrated that model with my
>> django web app using rest api.
>> I tested the API on postman and working.
>> now I want to get the result on front end using HTML CSS and javascript.
>> so how can I achieve it?
>>
>> On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
>> duncansantiag...@gmail.com> wrote:
>>
>>> hello, am not sure what the question is. Kindly elaborate.
>>>
>>> On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER 
>>> wrote:
>>>
 I am working on a django based project in which I have integrated ML
 trained models to check if a https url is legitimate or not. for this I
 need javascript or ajax to call a rest api for my form in which I want to
 send a post request so that I can check if a https url is legitimate or 
 not.
 *NOTE: My code is running successfully and giving correct answers on
 postman.* so just want to integrate it with my HTML form.
 *My work:*
 *form.html:*
 
 
   
 
 
 

 
 https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
 rel="stylesheet"
 integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
 crossorigin="anonymous">

 SITE URL Form
   
   
   
   
 SITE URL
 
   
   POST
 

 

 
 
   (function () {
 var output = document.getElementById('output');
 document.getElementById('post').onclick = function () {
   var data = document.getElementById('data').value;

   axios.post('http://127.0.0.1:8000/predict/',
 JSON.parse(data))
 .then(function (res) {
   output.className = 'container';
   output.innerHTML = res.data;
 })
 .catch(function (err) {
   output.className = 'container text-danger';
   output.innerHTML = err.message;
 });
 };
   })();
 

 

 
 https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
 integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
 crossorigin="anonymous">

 
 
   
 

 *myapp/urls.py:*
 path('form/', form, name="form"),
 path('predict/', predict, name='predict')
 *this is the response I am returning:*
 if list(model.predict([test]))[0] == 1:
 return JsonResponse({"Response":"Legitimate"})
 else:
 return JsonResponse({"Response":"Phishing or fake"})

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/e81cf4f0-1208-4623-97f9-4b88f01d67b3n%40googlegroups.com
 
 .

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.g

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread Duncan Santiago
do a demo, enter the URL on the text area and click on the post button.
Then send me the logs on the terminal running Django and also open the
console and send the output,

On Tue, 23 Nov 2021 at 10:21, DJANGO DEVELOPER 
wrote:

> okay let me explain.
> I have trained models which tells us that which website is legitimate or
> which website is not legitimate. I have integrated that model with my
> django web app using rest api.
> I tested the API on postman and working.
> now I want to get the result on front end using HTML CSS and javascript.
> so how can I achieve it?
>
> On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago <
> duncansantiag...@gmail.com> wrote:
>
>> hello, am not sure what the question is. Kindly elaborate.
>>
>> On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER 
>> wrote:
>>
>>> I am working on a django based project in which I have integrated ML
>>> trained models to check if a https url is legitimate or not. for this I
>>> need javascript or ajax to call a rest api for my form in which I want to
>>> send a post request so that I can check if a https url is legitimate or not.
>>> *NOTE: My code is running successfully and giving correct answers on
>>> postman.* so just want to integrate it with my HTML form.
>>> *My work:*
>>> *form.html:*
>>> 
>>> 
>>>   
>>> 
>>> 
>>> 
>>>
>>> 
>>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
>>> rel="stylesheet"
>>> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
>>> crossorigin="anonymous">
>>>
>>> SITE URL Form
>>>   
>>>   
>>>   
>>>   
>>> SITE URL
>>> 
>>>   
>>>   POST
>>> 
>>>
>>> 
>>>
>>> 
>>> 
>>>   (function () {
>>> var output = document.getElementById('output');
>>> document.getElementById('post').onclick = function () {
>>>   var data = document.getElementById('data').value;
>>>
>>>   axios.post('http://127.0.0.1:8000/predict/', JSON.parse(data))
>>> .then(function (res) {
>>>   output.className = 'container';
>>>   output.innerHTML = res.data;
>>> })
>>> .catch(function (err) {
>>>   output.className = 'container text-danger';
>>>   output.innerHTML = err.message;
>>> });
>>> };
>>>   })();
>>> 
>>>
>>> 
>>>
>>> 
>>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
>>> integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
>>> crossorigin="anonymous">
>>>
>>> 
>>> 
>>>   
>>> 
>>>
>>> *myapp/urls.py:*
>>> path('form/', form, name="form"),
>>> path('predict/', predict, name='predict')
>>> *this is the response I am returning:*
>>> if list(model.predict([test]))[0] == 1:
>>> return JsonResponse({"Response":"Legitimate"})
>>> else:
>>> return JsonResponse({"Response":"Phishing or fake"})
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/e81cf4f0-1208-4623-97f9-4b88f01d67b3n%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CACPcFdJ11YDrrpcCChwMcufz4CqcySacbKVQ-OtvEAVZEhK%3DBg%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKPY9pnmOXaLFnBRE4Eqi52yY-E%2BP1ih7arBDbxCqru4a-ZXxA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the 

Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread DJANGO DEVELOPER
okay let me explain.
I have trained models which tells us that which website is legitimate or
which website is not legitimate. I have integrated that model with my
django web app using rest api.
I tested the API on postman and working.
now I want to get the result on front end using HTML CSS and javascript. so
how can I achieve it?

On Tue, Nov 23, 2021 at 10:16 PM Duncan Santiago 
wrote:

> hello, am not sure what the question is. Kindly elaborate.
>
> On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER 
> wrote:
>
>> I am working on a django based project in which I have integrated ML
>> trained models to check if a https url is legitimate or not. for this I
>> need javascript or ajax to call a rest api for my form in which I want to
>> send a post request so that I can check if a https url is legitimate or not.
>> *NOTE: My code is running successfully and giving correct answers on
>> postman.* so just want to integrate it with my HTML form.
>> *My work:*
>> *form.html:*
>> 
>> 
>>   
>> 
>> 
>> 
>>
>> 
>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
>> rel="stylesheet"
>> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
>> crossorigin="anonymous">
>>
>> SITE URL Form
>>   
>>   
>>   
>>   
>> SITE URL
>> 
>>   
>>   POST
>> 
>>
>> 
>>
>> 
>> 
>>   (function () {
>> var output = document.getElementById('output');
>> document.getElementById('post').onclick = function () {
>>   var data = document.getElementById('data').value;
>>
>>   axios.post('http://127.0.0.1:8000/predict/', JSON.parse(data))
>> .then(function (res) {
>>   output.className = 'container';
>>   output.innerHTML = res.data;
>> })
>> .catch(function (err) {
>>   output.className = 'container text-danger';
>>   output.innerHTML = err.message;
>> });
>> };
>>   })();
>> 
>>
>> 
>>
>> 
>> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
>> integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
>> crossorigin="anonymous">
>>
>> 
>> 
>>   
>> 
>>
>> *myapp/urls.py:*
>> path('form/', form, name="form"),
>> path('predict/', predict, name='predict')
>> *this is the response I am returning:*
>> if list(model.predict([test]))[0] == 1:
>> return JsonResponse({"Response":"Legitimate"})
>> else:
>> return JsonResponse({"Response":"Phishing or fake"})
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/e81cf4f0-1208-4623-97f9-4b88f01d67b3n%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACPcFdJ11YDrrpcCChwMcufz4CqcySacbKVQ-OtvEAVZEhK%3DBg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKPY9pnmOXaLFnBRE4Eqi52yY-E%2BP1ih7arBDbxCqru4a-ZXxA%40mail.gmail.com.


Re: AJAX or Javascript POST request for Django form

2021-11-23 Thread Duncan Santiago
hello, am not sure what the question is. Kindly elaborate.

On Tue, 23 Nov 2021 at 09:19, DJANGO DEVELOPER 
wrote:

> I am working on a django based project in which I have integrated ML
> trained models to check if a https url is legitimate or not. for this I
> need javascript or ajax to call a rest api for my form in which I want to
> send a post request so that I can check if a https url is legitimate or not.
> *NOTE: My code is running successfully and giving correct answers on
> postman.* so just want to integrate it with my HTML form.
> *My work:*
> *form.html:*
> 
> 
>   
> 
> 
> 
>
> 
> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css";
> rel="stylesheet"
> integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
> crossorigin="anonymous">
>
> SITE URL Form
>   
>   
>   
>   
> SITE URL
> 
>   
>   POST
> 
>
> 
>
> 
> 
>   (function () {
> var output = document.getElementById('output');
> document.getElementById('post').onclick = function () {
>   var data = document.getElementById('data').value;
>
>   axios.post('http://127.0.0.1:8000/predict/', JSON.parse(data))
> .then(function (res) {
>   output.className = 'container';
>   output.innerHTML = res.data;
> })
> .catch(function (err) {
>   output.className = 'container text-danger';
>   output.innerHTML = err.message;
> });
> };
>   })();
> 
>
> 
>
> 
> https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js";
> integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
> crossorigin="anonymous">
>
> 
> 
>   
> 
>
> *myapp/urls.py:*
> path('form/', form, name="form"),
> path('predict/', predict, name='predict')
> *this is the response I am returning:*
> if list(model.predict([test]))[0] == 1:
> return JsonResponse({"Response":"Legitimate"})
> else:
> return JsonResponse({"Response":"Phishing or fake"})
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e81cf4f0-1208-4623-97f9-4b88f01d67b3n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACPcFdJ11YDrrpcCChwMcufz4CqcySacbKVQ-OtvEAVZEhK%3DBg%40mail.gmail.com.