HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

I'm having trouble creating an ajax field


#1

I’m having trouble getting the ajaxfield.php sample code working that comes with the ajax implementation guide:
https://www.helpspot.com/helpdesk/index.php?pg=kb.page&id=159

I took the unchanged file “ajaxfield.php” and placed the file within my secondary portal directory:
/public_html/portal3/ajaxfield.php

Here are the steps I followed:

In the Dashboard I went to Admin > Organize > Custom Fields

I selected “AJAX Selection Field” > Go to Step 2

For Field Name I typed “Test Ajax”

For AJAX data URL I typed http://nameofmywebsite.com/portal3/ajaxfield.php

Under options I selected the appropriate category: “IT - Portal Redesign (public)”

Then I clicked “Create Field”

I went into Customize > Secondary Portals.

I looked at the Edit Portal page for my portal. Normally a custom field will appear in the Custom Fields list so I can check it off and have it appear on my request form but since the “AJAX Selection Field” cannot be a public field it does not show up.

Anyway, I went to my Request page and there is no AJAX Selection Field. I typed “Tim” in the First Name input box hoping something will dynamically appear or change. Nothing happens.

Other Notes:

I verified that the ajaxfield.php file is located at the URL that I inputted for AJAX data URL. When I go to that file directly it says:

"error on line 2 at column 1: Document is empty"

And if I look at the source it says:

Notice: Undefined index: sFirstName in /server-path-info/ajaxfield.php on line 9

Not sure if that matters.

Questions:

  1. Did I miss any steps to get the AJAX field to appear on the request page?

  2. Does any extra code need to be added to my request.tpl.php template?

  3. When using <ajaxfield> do I have to specifiy the custom field ID? I.e. <ajaxfield name="Custom23" id="Custom23"> ?

  4. Does the AJAX data URL need to be an absolute server path instead of a website URL?

Sorry about the density of this post, just want to make sure I give you all the info I can think of to help with troubleshooting. :wink:

Thanks for any help you can provide,
Mike S


#2

Before diving in deep on this, to be clear are you trying to get the ajax custom field type to work on the portal itself? If so that’s not possible. It can’t be a public field.

What you could do instead is use a regular text field and then using jQuery which I know you’ve got going already from your other post, build your own ajax auto complete. You could obviously use one of the many ajax auto complete libraries as well by including it on the portal page.

If in fact you’re having a hard time getting the ajax field to work on the staff request screen we can work through that, but sounds like you’re trying to get something to work on the portal and if you need that type of dynamic input setup you’ll have to set that up custom.


#3

Thank you for the clarification. Yes, I was trying to make it work on the portal to see if it would be a good alternative to coding up everything in jQuery. Now I know the AJAX custom field wasn’t meant for the front-end so I will go the jQuery route.