-
Junie Member
  
-
Posts: 53
Threads: 6
Joined: May 2017
Reputation:
-1
(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 
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.
-
Junie Member
  
-
Posts: 53
Threads: 6
Joined: May 2017
Reputation:
-1
(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
-
Paradinight Senior Member
   
-
Posts: 445
Threads: 6
Joined: Jun 2015
Reputation:
25
07-22-2017, 08:37 AM
(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?
|