Cross-domain access via JSONP in PHP laravel framework __div

Source: Internet
Author: User

The parameter transfer under the same domain name is easy to implement, but there are some limitations in Cross-domain domain. Of course, I can search a lot of introduction posts, here I jsonp this one-way cross-domain way to summarize, and attach a small example.


Problem Description:

Because of the development on the server, use the unused port number to distinguish between different projects.

Implementation 192.168.1.10:8888 can invoke parameters on the 8889 project. (Originating from single sign-on, required for verification)

192.168.1.10:8888 End:

1. Controller implementation:

Public function test ()
{return
    view (' Test ');
}

2. ' test.blade.php ':

 

192.168.1.10:8889 End:

1.controller implementation:

Public function test ()
{
    \debugbar::d isable ();
    $callback = Input::get (' callback ');
    $arr =array (' A ' => ' Panhe ', ' B ' => ' Dada ');
    return $callback. " ('". Json_encode ($arr). "')"; 
    return response ($callback.) ('". Json_encode ($arr). "')")->withcookie (' Test ', ' authverify ', 10000000, '/')
    ->header (' P3P ', ' cp= ') IDC DSP COR ADM DEVi taii PSA PSD Ivai Ivdi CONi His our IND CNT "');   
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.