Error when adding record via Ajax form

rhinoboy

New Member
I am getting an error when adding a record via an Ajax link, but I don't get the error when I add the record using the form itself.

The error I get is "SyntaxError: Unexpected token < in JSON at position 0"

I am running Joomla 3.7 under php 7 and I got the latest version of Fabrik from GitHub today, re-tested, and still got the error. Based on a similar forum post, I am attaching (what I think is) the relevant debug output from Chrome.

I can provide the login info and quick instructions on how to reproduce the error.
 

Attachments

  • JSON Error adding record Ajax.txt
    14.9 KB · Views: 26
The "Unexpected token < in JSON" almost always means that there is a PHP warning being thrown on the server, and the formatted error message is corrupting the returned JSON.

Open dev tools in Chrome, and have a look at the Network tab. You should see the AJAX call to the server when the form is submitted. Look at the Response tab, and you'll see the warning. Copy and paste here.

-- hugh
 
Okay, so I had error reporting on and when I turn it off, there is no error returned. So that problem is solved, but now that the Ajax form isn't throw an error, I have a different problem: The form has a re-direct to a list and the redirect is working, but it shows the list in the pop-up. Obviously that's not the behavior I want ... is there some way around this?
 
Although turning error reporting off will fix that JS problem, it's really only masking the problem. Best look on dev tools and find out what the error is.

Point me at the page for the redirect issue.

Sent from my HTC6545LVW using Tapatalk
 
I have to admit I don't know Chrome Dev Tools very well. I don't see an Ajax call. But I can tell you that with error reporting on, I was getting a series of errors on the Ajax form when it loaded. I just turned error reporting back on and I can't reproduce that issue.

Regarding the redirect issue (and you can see if Chrome Dev Tools is showing anything), here is how to get to that screen:
  • Login at selectify.1010development.com using "terrytest" for the username and password
  • Go to the "Candidate List" page (top menu, Tasks->My Candidates)
  • If you click the "Assign a Position" button, this loads the form in the same window and, upon saving, returns to the Candidate List screen using a re-direct.
  • If you click the "Add" link in the list, the Ajax window pops up, but the redirect also opens in the window after saving.
This site isn't live, so you can' t mess anything up in there.

I realize that if I didn't use a re-direct, the screen would normally return to the calling screen. The reason I have the redirect in there is because if the Candidate is not already in the list, you would use the "Add a Candidate" button. That calls a different form that then uses a redirect to the "Assign a Position" form, passing parameters. It's okay to add a Candidate without assigning a position, but usually the user wouldn't do that and I didn't want to make it two separate steps.

I arrived at this setup through a convoluted process and I imagine (okay, "fear") that the answer is to re-do the forms/lists to operate differently.

My early background was from dBase back in the day (and we're about the same age, so you were there "back in the day") and I sometimes struggle with how my database knowledge/experience maps to Fabrik.
 
I added the login to my-sites. I didn't specify a phpMyAdmin login. That'll take me a while to get into. Let me know if it's holding you up.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top