Return Html From Jquery Get Request
I'm attempting to return an HTML form from a GET request triggered by jQuery but I'm not sure how to go about doing this. A customer's server will call to mine which will then retu
Solution 1:
As I said in my comment, you could use AJAX
or in your case GET
(http://api.jquery.com/jQuery.get/) and it allows you to return html.
Example:
$.get("yourPHP.php", {var: somethingdynamicpassedviajavascript},
function(data){
//get the result
$("#yourdiv").html(data);
}, "html");
The end of this function has the return type (in this case "html"). This example would place the HTML into the div #yourdiv
Solution 2:
If you'll eventually use JSONP, you'll have to make the form markup a string, which should be the value of a property of the json-encoded object the server is responding with.
So, your server will have to echo something like this:
<?php$o = newstdClass();
$o->formHTML = '<form>...</form>';
echo json_encode($o);
?>
Post a Comment for "Return Html From Jquery Get Request"