简体   繁体   English

在file.php刷新后从JQuery.load('file.php')传递JSON吗?

[英]Pass JSON from JQuery.load('file.php') after on file.php refresh?

I am really sorry if this is confusing, I really had no idea how to word this. 如果这令人困惑,我真的很抱歉,我真的不知道该如何措辞。

I have a Hybrid App, and I want to allow a user to log via Twitter. 我有一个混合应用程序,我想允许用户通过Twitter登录。 I am using TwtterOAuth. 我正在使用TwtterOAuth。 Using Ajax load, I am able to get the authorising page into the app I do this by setting a php file on a server, which the app calls. 使用Ajax加载,我可以通过在服务器上设置应用程序调用的php文件,将授权页面添加到应用程序中。 This is then loaded into a div on the app, albeit a little messy. 然后将其加载到应用程序的div中,尽管有点混乱。

But the user needs to sign in, and then authorise. 但是用户需要登录,然后授权。 Which I think is 2 refreshers. 我认为是2个复习。 On the last refresh it should send me the users tokens which I can then use in telerik backend to set up the user. 在最后一次刷新时,它应该向我发送用户令牌,然后我可以在telerik后端中使用该令牌来设置用户。 I am unsure how I can retrieve the JSON object out of the last refresh of the PHP file, and use it in the app. 我不确定如何从PHP文件的最后一次刷新中检索JSON对象,并在应用程序中使用它。 Normally one would use $.getJSON. 通常,将使用$ .getJSON。 But because there needs to be interaction, I am not sure how to do it ? 但是因为需要互动,所以我不确定该怎么做?

So I am using a modal div to load the auth: 所以我正在使用模式div来加载auth:

$('#twitterModContainer').load('http:twcall.php');

Which shows me the authorise page on Twitter, waiting for the user to login, and click authorise. 这向我显示了Twitter上的授权页面,等待用户登录,然后单击授权。 How would one proceed ? 一个人将如何进行?

You can pass data as a second argument on .load() function. 您可以将数据作为.load()函数的第二个参数传递。

$('#twitterModContainer').load('http:twcall.php',{ data: value });

This will get passed as arguments which you can latter call them on the script as : 这将作为参数传递,您可以稍后在脚本上将其称为:

$_POST["data"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM