Welcome Guest, Not a member yet? Register   Sign In
Can't read form values
#31

(07-22-2017, 04:29 AM)Paradinight Wrote:
(07-19-2017, 05:12 AM)Junie Wrote:
(07-19-2017, 01:49 AM)Martin7483 Wrote: Remove the enctype="multipart/form-data" attribute from the opening form tag

That attribute is only needed when uploading files.

I missed this up untill now, but that indeed could be the cause.
If you do require uploading files in the future, you will need to do this;

Code:
function save(form) {
   // NO!!! Don't do this!
   var formData = $(form).serialize();

   // YES!!! Do this!
   var formData = new FormData(form);

   $.ajax({
           url: url,
           type: "POST",
           data: formData,
           dataType: "JSON",
           ......
           ......
}

Sir, 

But for now, I just need input text and removing the enctype="multipart/form-data" doesn't change anything. My idea of creating a one-page CRUD in codeigniter seems too hard for a beginner. If I can't correct the errors I may use the modal way but as this moment I will stick on one-page crud. 
Thanks for the TIME.

1. new FormData(form); is the new way, but the old way do it too (.serialize())
2. the ajax method does not know about multipart/form-data. It does not care about it.

You have only one problem. you does not know how to debug you code Smile
Use the developer console. Every browser has a developer console.

if you send the ajax request, check the developer console. In the network tab you see an entry. Make a screenshot from it.

Sir,

When I try to look up into the developer's console in the NETWORK TAB. I found nothing. The way I debug the code is to trace every action that's what I did. It's just I missed somewhere else.
Reply
#32

It should be an entry. After the click on the button.
Reply
#33

(This post was last modified: 07-22-2017, 07:49 AM by Junie.)

(07-22-2017, 07:34 AM)Paradinight Wrote: It should be an entry. After the click on the button.

This is the screenshot. It shows it contains the input text. In the second screenshot still array= 0 when I tried to var dump in the controller add_agency.. I'm always confused why does It didn't follow the URL path which is url = "<?php echo site_url('agency/add_agency')?>"; in the if condition. And if I change the path of the URL in the AJAX it does work perfectly. btw, I already found a snippet to my ONE-PAGE crud and it works perfectly without the ajax method but it needs more improvement.

Attached Files Thumbnail(s)
       
Reply
#34

(07-22-2017, 07:39 AM)Junie Wrote:
(07-22-2017, 07:34 AM)Paradinight Wrote: It should be an entry. After the click on the button.

This is the screenshot. It shows it contains the input text. In the second screenshot still array= 0 when I tried to var dump in the controller add_agency.

xhr not js Smile
Reply
#35

(This post was last modified: 07-22-2017, 08:08 AM by Junie.)

[attachment=930 Wrote:Paradinight pid='345569' dateline='1500734682']
(07-22-2017, 07:39 AM)Junie Wrote:
(07-22-2017, 07:34 AM)Paradinight Wrote: It should be an entry. After the click on the button.

This is the screenshot. It shows it contains the input text. In the second screenshot still array= 0 when I tried to var dump in the controller add_agency.

xhr not js Smile

my mistake sir, it calls back into the view

Attached Files Thumbnail(s)
   
Reply
#36

(07-22-2017, 08:03 AM)Junie Wrote:
(07-22-2017, 07:44 AM)Paradinight Wrote:
(07-22-2017, 07:39 AM)Junie Wrote:
(07-22-2017, 07:34 AM)Paradinight Wrote: It should be an entry. After the click on the button.

This is the screenshot. It shows it contains the input text. In the second screenshot still array= 0 when I tried to var dump in the controller add_agency.

xhr not js Smile

my mistake sir,

pls the header part not the preview.
Reply
#37

(07-22-2017, 08:08 AM)Paradinight Wrote: pls the header part not the preview.

I think I missed in part of the jquery

Attached Files Thumbnail(s)
   
Reply
#38

(07-22-2017, 08:16 AM)Junie Wrote:
(07-22-2017, 08:08 AM)Paradinight Wrote: pls the header part not the preview.

I think I missed in part of the jquery

i need the headers part from the xhr requests
Reply
#39

(07-22-2017, 08:26 AM)Paradinight Wrote: i need the headers part from the xhr requests

Code:
GENERAL
Request URL:http://localhost/csc/agency
Request Method:POST
Status Code:200 OK
Remote Address:[::1]:80
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source

Cache-Control:no-store, no-cache, must-revalidate
Connection:Keep-Alive
Content-Type:text/html; charset=UTF-8
Date:Sat, 22 Jul 2017 15:30:00 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/7.0.15
Set-Cookie:ci_session=pbku6lrq6avj80jbqe7nen5pupomueqp; expires=Sat, 22-Jul-2017 17:30:00 GMT; Max-Age=7200; path=/; HttpOnly
Transfer-Encoding:chunked
X-Powered-By:PHP/7.0.15


Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:76
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:ci_session=pbku6lrq6avj80jbqe7nen5pupomueqp; style=null
DNT:1
Host:localhost
Origin:http://localhost
Referer:http://localhost/csc/agency
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Data
view source
view URL encoded
agency_id:
input_name:qq
input_category:qq
input_address:qq
input_acronym:qq
Reply
#40

(This post was last modified: 07-22-2017, 08:38 AM by Paradinight.)

(07-22-2017, 08:31 AM)Junie Wrote:
(07-22-2017, 08:26 AM)Paradinight Wrote: i need the headers part from the xhr requests

Code:
GENERAL
Request URL:http://localhost/csc/agency
Request Method:POST
Status Code:200 OK
Remote Address:[::1]:80
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source

Cache-Control:no-store, no-cache, must-revalidate
Connection:Keep-Alive
Content-Type:text/html; charset=UTF-8
Date:Sat, 22 Jul 2017 15:30:00 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/7.0.15
Set-Cookie:ci_session=pbku6lrq6avj80jbqe7nen5pupomueqp; expires=Sat, 22-Jul-2017 17:30:00 GMT; Max-Age=7200; path=/; HttpOnly
Transfer-Encoding:chunked
X-Powered-By:PHP/7.0.15


Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:76
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:ci_session=pbku6lrq6avj80jbqe7nen5pupomueqp; style=null
DNT:1
Host:localhost
Origin:http://localhost
Referer:http://localhost/csc/agency
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Data
view source
view URL encoded
agency_id:
input_name:qq
input_category:qq
input_address:qq
input_acronym:qq

Status Code:200 OK <- no 500. it is not the same requests.

edit:

Request URL:http://localhost/csc/agency <- is the url right?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB