• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Submitting Web Forms using AJAX and jQuery UPDATE

Contributor ,
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

Hi Fellow BC users,

Upon trying to use the Ajax form submission method I found that it's not working as documented on the KB:

http://kb.worldsecuresystems.com/851/cpsid_85119.html

I have received confirmation from BC tech guys that this has been fixed and the KB will be updated.

I don't know what exactly was fixed/ changed but I asked BC tech guys to post an update here in the forum.

So for any of you who want's to use the Ajax/ jQuery effect please note that the KB will be updated.

Cheers

Micha

Views

2.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

Go to demo.worldsecuresystems.com and look at the example on that site. It

works there and there are also step by step instructions on how to

implement it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 26, 2013 Feb 26, 2013

Copy link to clipboard

Copied

Thanks Mario,

I guess BC support don't have a clue what's going on in there messy KB pages.

Here is a screen shot of the changes in the script.

ajax-changes.png

Cheers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

Hi Mario

Is there a way to make this work with an Update user details form i.e. forms with action="/MemberProcess.aspx"?

I get a 400 (Bad Request) error when trying to apply this method. I have searched around adn connot find any info on this.

Thanks

Tim

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

The JSON element is only availible for the main web form process. You can not do that the same way with other forms. ANY form though can be ajaxed.

The best thing you can do is understand jQuery Ajax:

http://api.jquery.com/jQuery.ajax/

Looking at things like dataType etc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

Thanks for the advice Liam.

Turns out I had this working previously before I found this article and added JSON=1 but it didnt appear to be doing anything.

I am attempting to update the value of a custom CRM field (checkbox list). I added a FirstName field and this updates successfully.

EDIT: Sorry I lied when I tested and changed the FirstName I was on a page I had used a webform to post the data which worked for updating all data but has the drawback of creating cases and requiring user name and email to be sent. Back to square one.

Is the problem perhaps in the data I am sending? currently created through .serialize():

FirstName=Tim&CAT_Custom_252221_90921=AtoB&CAT_Custom_252221_90921=Craft

Should this be

FirstName=Tim&CAT_Custom_252221_90921_0=AtoB&CAT_Custom_252221_90921_1=Craft

Is it preferable to send a string like above or an object?

And lastly if the success function is triggered is it safe to assume the record will be updated as the response I get is an HTML string of the page so I am not sure how to check for success like you can with a JSON response as shown in the linked KB from the OP.

Thanks alot and sorry if any of this is basic knowledge, I am entirely self taught so some things are bound to have slipped through the cracks.

Tim

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

There are two things to a form, POST and GET.

You can fetch data in ajax or post ajax data.

JSON is the return information - it is returned in a JSON format to process.

JSON and JSONP exist because the format is string like you can use for data transition and then convert back into an object etc

JSON response in BC only works on the web forms. Everything else will return html. So you have to handle that yourself.

Asking what your asking is not a problem, JSON only being on web forms etc is not well outline properly in the BC docs, the jQuery link on Ajax and reading through that when you can though will help you understand the core and basics of what you pass and what is returned. Once you have a good grasp of that you can use ajax in BC or elsewhere and be able to handle what comes back and what you send and what you do with it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

Thanks for you input Liam. I got it working.

My ajax function was fine the problem was the data I was posting.

For others who read this ... when updating CRM data you MUST post data for

  • FirstName
  • LastName
  • EmailAddress

This can be kept as it was using {module_FirstName} etc

When posting to update custom CRM fields you need to include FormID=XXXXXX (the id of your custom CRM form).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

Doing a post but you understand the JSON aspect and why there is none though? That is important. And your handling failure etc?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 27, 2013 Mar 27, 2013

Copy link to clipboard

Copied

Even though bc doesn't return json on any firm but standard webform, you

can always parse the html it returns for errors. The best method imo is to

make it in jquery object and use jquery syntax on it the way you use it in

a standard page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 27, 2013 Mar 27, 2013

Copy link to clipboard

Copied

True , The return html can be read through but it is important to note that be it a BC success or fail it will be an ajax success. So how you handle it is key which it what I was refering to

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 27, 2013 Mar 27, 2013

Copy link to clipboard

Copied

My understanding of JSON not being available is that BC doesn't support it as a return for this form and obviously if JSON is not returned I cannot use it.

As for handling failure. I can parse the HTML and find the vaules for the feilds I am editing or in the case of the checkbox list the output of {module_customerfield,XXXXX,XXXXXX} and confirm it matches the data sent.

Though this seems a little clunky is there a more efficent method?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 20, 2015 Aug 20, 2015

Copy link to clipboard

Copied

LATEST

Did you ever get this to work with "Update User Details" form for the CRM and Extended CRM?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 27, 2013 Mar 27, 2013

Copy link to clipboard

Copied

Hi

http://www.weightlossmentorprogram.com.au/joinnowtest

1.   I have implemented your example and when it submits the message and the form on the page is seen for a second and then it disappears. Why would this be?

2.  I am trying to submit 2 forms with 1 button.  The form will submit the customers details into backend of BC and then the button will take the user offsite to Paypal to pay the monthly subscripton.

Doesn't seem to be working.

Ta

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines