-1

Please let me know answer if any one knows about it.In which scope my ajax data send from view to handler in coldbox

SREERAM
  • 1
  • 4
  • 2
    Please add code to your question. What do you have, what do you expect? Elaborate what exactly you do not understand. Help us to help you. – Alex Aug 02 '18 at 18:35
  • Actually i'm sending form data using jquery as following code $("#submit_btn").('submit', function(){ $.ajax({ url: 'deals/addmerchant', type : "POST", dataType : 'json', data : $("#MerchantForm").serialize(), }, } }) }); – SREERAM Aug 03 '18 at 02:05
  • I'm dumping form data in handler as follows ,BUT I'M NOT GETTING ANY DATA IN DUMP – SREERAM Aug 03 '18 at 02:06
  • If you're new to S.O., comments are frequently deleted. Could you please [edit] your question and add the code above, so it is more visible to others, and easier to read? :) Then delete the comments. – SOS Aug 16 '18 at 18:19

1 Answers1

0

When you're making an ajax POST, it gets treated as a brand new request. This means you'll need a separate route and handler for that request.

Within your new handler (let's call it /handlers/data.cfc) you'll want to format your response appropriately for your code. ColdBox comes with some nifty tools to help you do this. One way would be to use renderData() within your handler or view.

Rough example:

event.renderData( type="json", data=yourData );

Once set up correctly, the ajax calling code should receive the formatted data from your new handler as expected.

Side note: I recommend including code samples when asking questions on StackOverflow. It will help those that want to provide assistance understand exactly what you are trying to do.

Dave L
  • 3,095
  • 3
  • 16
  • 25