CakePHP Ajax Add form from View (related ) - ajax

i´ve got a view of my client (http://localhost/client/view/3) and in related section I have his adress.
Cakephp automatically builds that. When you click on Add Adress button new page comes up (http://localhost/addess/new) and when you save that it goes to http://localhost/addess/index
what I need is to ajax this view and get all working together. I need to go to http://localhost/client/view/3 push Add Adress and get addrees/new form visible (<- easy with jQuery) but how can I save the new adress and get adress div updated??
any example??
thanks

The php script you make the AJAX call to is where you need to do the save. When you have done that, you can pass out the data for the address div as xml or a javascript object and read it with the AJAX javascript in the original view.

Related

Attach or embed node add form with a view

I am using Drupal 7.54. I want to attach or embed a node add form to a view so that when a user submits the form, the view below the form will be updated in realtime via ajax. The form will be shown above the view. My view block name is Statuses Stream.
I tried Form block module and putting the form in the header section of my view using views ui, but after submit, it was redirecting to the node created page.
Then I tried Advanced Form Block module. I created a form using AFB module. The form name is Statuses. It is submitting the form with ajax, but it is not updating the view in the realtime. I have to refresh the page manually to show the created node below the form.
I am open to any solution programmatically or through a module.
Note: For those who know, I am trying to mimic the statuses module. It does exactly what I am looking for. The problem began when I came to know that it is not an entity. So now I am trying to make the same functionality with Content type.
You could use something like Views Refresh to manually update the view below instead of refreshing the page.

Scala Play - calling controller method from view doesn't load a new page

I display information, gather some user's input, and call a controller method using ajax/java script call from the view. However, instead of displaying a new/different html page, the controller method returns back to the original html page that I called jscript from.
Is this because of ajax call? How do I make sure that controller method would display the html file it's supposed to, instead of staying on old html page?
It sounds to me like what you want to do is to open a different url than the one you are on. To do that you do not use ajax. Instead try using javascript to change window.location to tell the browser to go to the url (or 'call your controller'). It looks like this:
window.location.assign("/your/controller/url"); // or
window.location = "/your/controller/url";
There is more to read about it here: https://developer.mozilla.org/en-US/docs/Web/API/Window.location
You can think of ajax as a separate little browser that lets you call the web server but letting you handle what comes back with javascript rather than always showing it to the user. So if you want to do the call with ajax but get the response HTML into your page, you are responsible for taking that response and inserting it into the DOM.

Wordpress, how to use AJAX to return result of shortcodes and change displayed forms on page

Currently I am working on a wordpress site. What I want to do is:
Changing the used contact form (over shortcodes, done by a plugin), everytime the user changes his selection of options provided by a dropdownlist with one form as the default one.
I want to achieve this by using ajax. I could send the Index of the selected option to a php file, but I dont know how exactly I would execute the shortcode in php and return the result to the wp site.
Any information and advice would be great!

Is AJAX only for dynamic content or can it also create buttons, and change css properties?

I was wondering, is Ajax only for dynamic content update or can it also, say, create a few buttons in a given div depending on what action a user chooses in another div? For example, if the login page and first page look very similar by only a few buttons, once proper login credentials are entered, can I use Ajax to make the other three buttons appear once logged in properly, rather than going to a whole another web page that has those buttons hard coded in the html/css? If this is possible, I'll take pointers to any tutorials. Thanks.
AJAX is just for creating HTTP requests using javascript, in order to prevent full page requests.
What you can do is to process the login request using AJAX and then, depending on the response you send, to display an error or update the DOM with the logged in interface.
If you just want to change the DOM, you use javascript directly (jquery would help) but no AJAX is needed.

flashmessenger can`t show anything when page loading with ajax

i have a form that it send data with ajax post metod. when i set flashmessenger in action method, it don`t show any messege (i have to refresh the page for see the messege)!
how i can manage the flashmessenger for recognition ajax load page??
Flashmessenger uses sessions, in order for it to work you need to physically reload the page. You have to create your own mechanism; Whenever you get the callback you can append lets say your response to the same element in which you would have displayed the flashmessanger message.

Resources