Note that there are some explanatory texts on larger screens.

plurals
  1. POTell Controller On Another Domain There Is New Data
    text
    copied!<p>Currently I have two sites hosted on different domains.</p> <p><strong>SITE 1:</strong> I want to use as a CMS for content creation only. (writing,editing,etc.)</p> <p><strong>SITE 2:</strong> I want to use for viewing content.</p> <p>Theoretically, what I'd like to be able to do, is create multiple peices of content in <strong>SITE 1</strong>.</p> <p>When I'm ready to publish these I'll press a 'publish' button, which will alert <strong>SITE 2</strong> that there is new content and pass the values via JSONP.</p> <p><strong>SITE 2</strong> will then pull in the data via JSON and do what it wants...(enter into DB, etc.)</p> <p>...so yeah I'm stuck at the theoretical part. I'm not exactly sure where to go now but here's what I'm thinking.</p> <p>There's a javascript function on <strong>SITE 1</strong> that is called when I choose publish:</p> <pre><code> $.ajax({ type: "POST", dataType: "jsonp", data: postData, url: 'http://site2.com/admin_json_controller.php', success: function(data) { // 'data' is a JSON object which we can access directly. // Evaluate the data.success member and do something appropriate... if (data.success == true){ alert('worked!'); } else{ alert('did not work!'); } } }); </code></pre> <p>This posts a json object to a php file on <strong>SITE 2</strong>. This file will simply be waiting for this post object. When it recognizes the post object...it will then enter the values into the database.</p> <p>Does this make sense? I have a feeling I don't quite understand JSON yet but any help, questions, tips, pointers are much appreciated.</p> <p>THANKS</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload