So I'm in my edit view... let's says it's posts/edit/1
That page loads some Javascript which makes a $.get call that pulls data from a different action on the same controller (posts/foo).
How can I simply send the current model's ID to AJAX, and on to the other controller?
In this case, both actions are in the same controller, but I'm not sure that helps in this case.
if you are using jquery you can have something like this
$(document).ready(function(){
//ajax call here
});
The thing is that once your document has loaded you just send this id to the other controller.
I hope that helps
If you only need to get the Post ID from your edit view, this is the variable you need:
$this->Form->fields['Post.id']
If its not "Post", just replace it with the model name you are using and trying to get the ID for.
UPDATED: Based on the clarification: you are right; for what you are trying to do, you need to generate the link or just the unique ID in a script tag, and then somehow use that variable in your included script. Take a look at how I did it for a CakePHP plugin. A quick summary:
Something like this:
<script type="text/javascript">
id = '<?php echo $this->Form->fields['Post.id'] ?>;
</script>
and then use this id variable in your included Javascript file.